Hiding Objects in Scene Editor?

Is there any way to have objects hidden or created during runtime in a scene so I don’t have t clutter up the scene with things like my scanline tiled sprite for scanline effects?

Lots of options. You could nest them, and turn off the parent (turn on at runtime). You could use layers and turn them of in editor. You could also store as prefabs (one or bunches) and spawn them. Many ways, some have different costs though.

Don’t scale objects to zero :slight_smile:

If you take the SetActive option, bear in mind that GameObject.Find won’t find inactive objects, but Transform.FindChild does. You may hold a reference in your code to those game objects and then activate/deactivate them (or a parent group).

Well I was searching and I found a good way to do it is to Instantiate prefabs but I couldn’t get it to work because I’m using C# and everything I found was in javascript and I’m by far not even advanced enough to write code without asking these simple questions. :stuck_out_tongue:

Yes, use prefabs as much as possible in Unity. Prefabs are a great componentization pattern, and will allow you to store and reuse quickly pack different relates structured together: hierarchy of gameObjects, materials, components (behaviours), …

The way you instantiate them in C# usually is:

  • You load them from Resources folder:
GameObject x = Resources.Load<GameObject>("path_from_resources_folder/name of prefab file).
  • Instantiate as many times you need:
GameObject instance = GameObject.Instantiate(x) as GameObject

I often use HideFlages Unity - Scripting API: HideFlags

I managed to create the object with the instantiate code that you posted Thrawn75, but now I can’t seem to manipulate the object that was created.