- Home /
add gameobject via the inspector?
i want to add a gameobject via the inspector and not at runtime
if i make a custom inspector with a button , i want to add a gameobject and then add collider
so that i can see them in the inspector how do i do this
Answer by CodeMasterMike · Nov 26, 2012 at 06:55 AM
If you want to be able to add a gameobject through the inspector, all you need to do is to make is set a public gameobject in your script:
public class myClass : MonoBehaviour
{
public GameObject myGameObject = null;
}
Then when you set your script to a object you will see the gameobject parameter in the inspector. You don't need to work around with a custom inspector, just use the default one.
Good luck!
Your answer
Follow this Question
Related Questions
How do you get the default inspector to draw for Prefabs ? 2 Answers
Can a GameObject's full inspector be drawn in a custom Editor Window ? 1 Answer
Editor GUI: Object preview icon 2 Answers
Questions Regarding Images in Custom Inspector/Editor 1 Answer
Simple text in inspector components? 2 Answers