- Home /
Question by
3dDude · Nov 22, 2010 at 05:04 PM ·
javascripteditor
scripting problems with editorGUI
hello.
I asked a question a few days ago here
and i got this answer:
using UnityEngine; using UnityEditor; [CustomEditor(typeof(Scale))] public class ScaleEditor : Editor { public override void OnInspectorGUI() {
base.OnInspectorGUI();
if (GUILayout.Button("My editor button"))
{
myFancyFunction();
}
}
}
I have a deferent script(javascript) named Scale and I need to edit this script to call a function from it. this probably seems like a noob question but I need help.
thanks
Comment
Best Answer
Answer by Molix · Nov 22, 2010 at 05:42 PM
The Editor class has a member called target which refers to the item being edited. So you can do something like:
public override void OnInspectorGUI() { Scale scaleBeingInspected = target as Scale;
DrawDefaultInspector(); if (GUILayout.Button("My editor button")) { scaleBeingInspected.SomeFunction(); } }
Your answer
