- Home /
Custom objects from editor scripts?
Hey, folks!
So, I've got an object -- called Cat, for example. And I want to display that in the Unity Inspector, with all its variables. Is there an easy way of doing this when you are also attempting to edit how the Inspector works? It seems to work quite easily when you're just plugging them in with [System.Serializable], and not touching the inspector with an Editor script. But when you are, it seems you can't just cause it to appear with its variables when you call object.FindProperty("_catObject");. Have you tried this? How does it work?
Not sure what you mean. IF you mean a Class named Cat with some variables in C#, just make a public class w/ public variables like so:
using UnityEngine;
using System.Collections;
public class Cat : $$anonymous$$onoBehaviour
{
public float testFloat = 1.0f;
public string testString = "cat";
public int testInt = 1;
public GameObject testGameObject;
public Transform testTransform;
void start()
{
}
void Update()
{
}
}
Sorry, I meant when you declare them and want them to be editable in a script that modifies the inspector window! Thanks, though.
Oh sry lol XD
I voted your question up as well as the accepted answer because I learned something new, thanks :)
Answer by Loius · Dec 18, 2012 at 05:51 PM
If in your InspectorGUI function you use "DrawDefaultInspector()", that will do the default inspector for the object. You can "[HideInInspector]" any public variables you don't want to show up in that, and it'll draw the default inspector for your subclasses.
This is the answer I was looking for! Thanks, I'll check it out.