Need help in Creating Game Object by codes

Hi, I know how to create game object by codes but can I create a GameObject which only available in Editor but not during PlayMode?

What I mean is let say in Editor I’ve created a GameObject - A through codes.
After that once I click on Play, the A will automatic destroyed.

Is it possible to do something like this in Unity?

if u totally dont need that object in game use the following script in a file and attach to it…

function Start()
{
Destroy(gameObject);
}

if u need the object for some calculation and dont want that to be shown in the game use

function Start()
{
transform.GetComponent(“MeshRenderer”).enabled=false;
}
}

you can also untick the gameObj
using active

What is your end goal with this? Seems a bit silly to have the runtime first load the GameObject and then spend more work on immediately tearing it down.

Please read this before posting. http://forum.unity3d.com/threads/97860-Read-this-before-posting-questions-in-the-scripting-section?p=638874#post638874

Heh, not every answer is “go find it”. In this case… he posted correctly though I don’t think anyone has explained to him the usefulness of Prefabs.

Create a prefab of your object, In your code when you define a member like a Transform or GameObject, drag the prefab to it, instead of something in the scene. This way, you can create and destroy objects as you need and they are really never in the scene to start.

This is a great method to do bullets and other objects which really don’t exist in the scene until they are ready.