x


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

more ▼

asked Nov 22, 2010 at 05:04 PM

avatar image

3dDude
3k 185 162 183

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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(); } }

more ▼

answered Nov 22, 2010 at 05:42 PM

avatar image

Molix
5.6k 41 60 114

thanks so much!!! perfect! :D

Nov 22, 2010 at 07:39 PM 3dDude
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x8106
x3347

asked: Nov 22, 2010 at 05:04 PM

Seen: 1454 times

Last Updated: Nov 22, 2010 at 05:04 PM