Say if I had a custom class that doesn’t extend Monobehavior called “Test.js”:
#pragma strict
class Test
{
var min: float = 0;
var max: float = 1;
var current: float = .5;
}
and I make an instance of in a script called “ShowTest.js” that does:
#pragma strict
var testVar: Test;
and I make an instance of in a script called “OtherShowTest.js” that does:
#pragma strict
var testVar: Test;
and I have a Editor script for the class that’s in the Editor Folder called “TestEditor.js”:
#pragma strict
@CustomEditor(Test)
@CanEditMultipleObjects
class TestEditor extends Editor
{
var minProp : SerializedProperty;
var maxProp : SerializedProperty;
var currentProp : SerializedProperty;
function OnEnable () {
// Setup the SerializedProperties
minProp = serializedObject.FindProperty ("min");
maxProp = serializedObject.FindProperty ("max");
currentProp = serializedObject.FindProperty ("current");
}
function OnInspectorGUI() {
// Update the serializedProperty - always do this in the beginning of OnInspectorGUI.
serializedObject.Update ();
// Show the custom GUI controls
EditorGUILayout.Slider (currentProp, minProp.floatValue, maxProp.floatValue, new GUIContent ("Current"));
// Only show the damage progress bar if all the objects have the same damage value:
if (!currentProp.hasMultipleDifferentValues || !maxProp.hasMultipleDifferentValues || !minProp.hasMultipleDifferentValues)
ProgressBar (currentProp.floatValue / maxProp.floatValue, "Value");
serializedObject.ApplyModifiedProperties ();
}
// Custom GUILayout progress bar.
function ProgressBar (value : float, label : String) {
// Get a rect for the progress bar using the same margins as a textfield:
var rect : Rect = GUILayoutUtility.GetRect (18, 18, "TextField");
EditorGUI.ProgressBar (rect, value, label);
EditorGUILayout.Space ();
}
}
Is there a way that I can make the custom editor information of “TestEditor.js” show up in an instance of the Test class in “ShowTest.js” and “OtherShowTest.js”?