What's best: Instantiate or LoadLevelAdditive?

I’m a little undecided on this one! Basically, I am loading the HUD on level start, and I have tried 2 different approaches.

My first approach was to create different HUD prefabs eg; HUD_TILT_CONTROLS.prefab, HUD_TOUCH_CONTROLS.prefabs, ect…
Then I use a ControlsManager class where I assign all different HUD prefabs to an array of GameObject, in the editor. Than at runtime, I Instantiate() the chosen HUD prefab, and if the user changes the HUD in the pause menu for example, I then Destroy() the current HUD prefab in the scene, and Instantiate() the new one chosen by the user. This approach works fine, but I don’t like the fact that the Instantiated HUD GameObject is a (clone), and I try not to Instantiate() too many things when I don’t have to.

My second approach is to create new scenes for each HUD preset, and depending on the user’s choice, I load the corresponding scene with LoadLevelAdditive(). I got the idea from the Penelope IOS tutorial. The nice thing about this approach is that I could also throw in other GameObjects in each scene, like the player for example, that way I can do all my testing/tweaking in each HUD scene without having to mess with the actual level scenes. And a bonus, at least in my mind, is that I don’t have to Instantiate() anything, and I get the actual GameObject(s), instead of clones.

Is one approach better then the other? Like performance-wise, or organization-wise? What do you guys recommend for loading HUDs at runtime?

Thanks for your time!

Stephane

I personally would use prefabs instead of loading another scene additive. I don’t really understand what you mean with “I don’t like the fact that the Instantiated HUD GameObject is a (clone)”, but I think that Instantiating your prefabs is a good choice. You could also place all HUD-objects in your scene and Enable/Disable the ones you need. That way you don’t have to Instantiate/Load at runtime which will never give you any frame-hiccups. It basically all depends on the number of prefabs you want to use. If you only switch between a couple of prefabs, I would just put them all in my scene and disable the ones I don’t need. Disabled gameObjects will cost practically nothing, so this is in a lot of cases the best (performance-wise) choice.

Is it an option to have a kind of parent HUD-prefab with all presets childed to that gameObject? That way you only have one prefab you can change in whatever scene you like and it will automatically be updated in all your other scenes. The only thing you have to do “manually” is to make sure that your parent-prefab is present in each scene, but you could also Instantiate that prefab through code.

If that’s not an option, I still suggest the prefabs solution, because it will be easier to maintain references to your objects and manage your HUD correctly.