0
\$\begingroup\$

I often see this kind of problem in projects: the scene contains many hierarchical objects that must be in a certain state to work correctly. If a disabled object has to be edited it has to be activated first, and if editing takes a long time it is difficult to remember its original state at the end, especially when there are several objects which states were changed. It leads to hidden bugs. I often take a screenshot of the expanded hierarchy before I start editing but I don't think this is a solution, it's more a method of minimizing the consequences.

So how to manage this problem correctly or what approaches you could recommend?

enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ I haven't seen this kind of problem in half a decade of working in Unity. Can you provide a more concrete example of a situation that forces you to do this complicated operation? With more context about the gameolay needs it's serving, we may ba able to suggest alternative ways to meet those needs without so much manual finagling. \$\endgroup\$
    – DMGregory
    Commented May 23, 2020 at 12:43
  • \$\begingroup\$ Added a screenshot one of the projects I've got to support. There are objects in different states on the scene. Each disabled object can also have different objects states in its tree. \$\endgroup\$
    – Serg
    Commented May 23, 2020 at 14:32

1 Answer 1

1
\$\begingroup\$

My solution to this problem is usually to have scripts which make sure that their children are in the correct activation state as soon as the game starts. For example, if I have an UIManger with several sub-objects representing windows of which only one should be open at game start, then the UIManager's Start() method would call SetActive(false) on all its children and then SetActive(true) on the main menu.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .