Search code examples
c#unity-game-engineunity-editor

Unity is possible to add a Game Object in hierarchy but not instantiate it?


I'm not sure if it is possible to create a Game Object in the scene (so it appears in the hierarchy) but I would like Unity to not instantiate (or rather remove it) such Game Object when I press play.

The reason why I want to do that. I'm creating Game Objects as 'enemy spawners' in my game. But I don't want to have those transforms or Game Objects actually in memory while the game is running. So I've created an editor script that search for all the spawner entities, retrieve the information that I need and creates a binary file with it that later the enemy manager reads in run time during the initialization process.

If this is not possible, do you guys have any recommendations on how I could implement something similar?

Many thanks in advance.


Solution

  • You are looking for scriptable objects.

    Here are some URL's

    ScriptableObject Tutorial from Unity

    ScriptableObject documentation

    ScriptableObjects can be accesed at any time and don't have to be instantiated before you can use them. So they won't have a transform.