Need quick editor scripting help
Hello everyone.
I need quick help with something.
Say I have the following serializable type:
[Serializable]
public class RotatorItem {
public float x, y, z;
}
In the inspector the default display is like so:
--------------------------
[Rotator]
X [ ]
Y [ ]
Z [ ]
-------------------------
How would I write an editor property drawer to make the it display the members like this:
------------------------------------
[Rotator]
X [ ] Y [ ] Z [ ]
------------------------------------
I know it's a lazy question but I have too much on my plate to get into learning editor scripting right now and will appreciate your help. I help a lot of people every day on various forums with Unity so I deserve it.
Answer by Jessespike · Apr 12, 2016 at 08:41 PM
The lazy answer is to use a Vector3 instead. Vector3 is a struct with 3 floats anyway.
[Serializable]
public class RotatorItem {
//public float x, y, z;
public Vector3 target;
}
If you still want a custom inspector, you just need to wrap the fields with: EditorGUILayout.BeginHorizontal and EditorGUILayout.EndHorizontal
Are you kidding me? The difference between bool and float is earth and sky. I want to make my editor as clearly understandable as possible. But thanks for your answer anyway, I'll just put editor scripting on my plate as well