karma icon indicating copy to clipboard operation
karma copied to clipboard

Prevent child objects from being applied to a prefab

Open JenkinJoe opened this issue 9 years ago • 6 comments

Hello there,

i came up with another problem that exists because of the philosophy of composing elements and align them separately during runtime. Imagine you got a hierarchy like: App > Start > Environment Camera Canvas If you apply your changes now to the Start Element that is a single prefab itself, it also saves it's children that you maybe applied for testing purposes in your hierarchy. But nevertheless this has to be a single prefab (without any children) because you want to instantiate and apply children to it while in runtime. According to this topic: http://answers.unity3d.com/questions/225304/is-there-a-hideflagsdontsave-equivalent-for-preven.html I assume that unity still didn't come up with a solution on their own, so what i wanted to ask you is how you manage to do it. What's your workflow?

Greetings, Joe

JenkinJoe avatar Jun 21 '16 09:06 JenkinJoe

Regarding that specific issue I guess Karma has the same problem since its really a problem of Unity itself. What I usually do is that I test individual Elements by themselves in some test scene, and focus on the benefits of composition + isolation. I've done some pretty heavy nesting and its worked out fine. I am really happy with the result regarding this matter.

cgarciae avatar Jun 22 '16 21:06 cgarciae

You have to keep in mind that I was not assuming it not to work. It's just a very tedious process that you can easily avoid by not applying the concept of mvpc, karma so to speak. Nesting works if you're working on it yourself and no one else. But how do you explain another employee let's say an artist when and how to delete children to keep the right structure for composition if the only work he does is the creating of visuals and not thinking about it's composition during runtime (what the programmer actually does)?

JenkinJoe avatar Jun 23 '16 09:06 JenkinJoe

Yeah I agree it can be tedious. In my mind a Character is most probably a single 'Element', the camera is another, the terrain can be part of the View's prefab, ect. I havent had problems with this, what is your specific issue?

cgarciae avatar Jun 23 '16 17:06 cgarciae

In the first scene, the entrance scene i have this hierarchy: start > camera, environment, canvas > title screen, main menu, options, audio options,... Now if i change canvas and apply it, it creates prefab with its children (title screen, main menu,...). Inside the canvas the children are presenters themselves.

JenkinJoe avatar Jun 23 '16 17:06 JenkinJoe

I take start is an App and canvas is a Presenter right? Its not wrong to put title screen, main menu, options, and audio options inside the canvas prefab as long as they dont need independent logic or are to be reused in other views. I've done an app with a Menu and wanted to reuse it, so I made it and Element, this means that it has its own prefab, presenter, etc, and then I just request it through DI on each View I want to use it.

cgarciae avatar Jun 23 '16 19:06 cgarciae

I reuse them for a later options menu in game. And the canvas shouldn't contain all elements on each purpose. But i think you got me and i hope there will be a solution soon.

JenkinJoe avatar Jun 24 '16 03:06 JenkinJoe