Creating Unity in Unity

el_bearduno's picture

On of the features I absolutely love about Unity is the hierarchy and inspector. Recently I wanted to be able to tweak settings in my game while on the go. Games are hard to get right and it takes tons of tweaking to get balance and settings just right. Also, I didn't want to have to create a custom interface for every single setting I wanted to change. Really, what I wanted was an In-Scene Unity Inspector. I looked everywhere to see if I could find one but I could not. So I did what most programmers wanting to save time would do: I spent a bunch of time creating one.

Step 1: Inspection

To start, I created a basic class that needed a reference to a scene object and a component in that object. Then, I used the System.Reflections library to browse through all the accessible (Public and Serializable) members and properties. Lastly, I have some prefabs for different types, right now just bool and everything else is a text field. I initialize the prefab and add events to edit the live values.

Step 2: Browsing

With Step 1 completed, I really just barely scratched the surface of what the Unity inspector is doing. The next part was easier though. I wanted to be able to edit any object and all of its accessible values. For this step,  I used the basic Unity libraries to get a list of all the objects and iterate down through their children to make a nice parented list. From here I just needed an interface linked to a drop down list. The result is still not glamorous but we're getting there.

There is sill work to be done but this is a nice start. Thanks for stopping by to read and feel free to offer up any suggestions on where to go from here.

Add new comment

Basic Editor

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain Text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.