Plugin Debugging: New Beta Feature!

I wouldn’t call it “officially advised”, but it’s almost certainly better practice:

  • That component that you thought you only needed one of and moved over? Now you need another of it and you have to rewrite some of your code to support it.

  • If you’re moving over stuff rather than cloning it that’s a suggestion that your code is very far from being testable. (most people don’t do any testing of their code in the community right now, but we would like to promote more of that)

  • Your lifecycle changed (for example… thanks to using the plugin debugger!), and now you need to create the Gui twice is a session instead of once. Moving it back might kinda work, but things would probably have been simpler if you just cloned it in and destroyed the tree after you were done with it, moving it back out instead of destroying it is a very easy way to leak instances or other memory.

  • Also, don’t worry about perf. Actually creating the graphics objects and general rendering state to render the Gui is generally way more expensive than having one extra copy of the static parts of the Gui sitting around inactive in memory.

TL;DR: Just clone it, it’ll cost you nothing and you’ll probably save yourself trouble at some point.

3 Likes