using UnityEngine; using UnityEditor; using System.Collections;
publicclassScriptableWizardButton : ScriptableWizard { public Transform firstObject = null; public Transform secondObject = null;
[MenuItem("Example/Show OnWizardOtherButton Usage")] staticvoidCreateWindow() { ScriptableWizard.DisplayWizard("Click info to know the distance between the objects", typeof(ScriptableWizardButton), "Finish!", "Info"); }
voidOnWizardUpdate() { if (firstObject == null || secondObject == null) { isValid = false; errorString = "Select the objects you want to measure"; } else { isValid = true; errorString = ""; } } // Called when you press the "Info" button. voidOnWizardOtherButton() { float distanceObjs = Vector3.Distance(firstObject.position, secondObject.position); EditorUtility.DisplayDialog( "The distance between the objects is: " + distanceObjs + " Units", "", "Ok"); } // Called when you press the "Finish!" button. voidOnWizardCreate() { EditorUtility.DisplayDialog("OnWizardCreate ", "", "Ok"); } }
// Add menu named "My Window" to the Window menu [MenuItem("Window/MyEditorWnd")] staticvoidInit() { // Get existing open window or if none, make a new one: MyEditorWnd window = (MyEditorWnd)EditorWindow.GetWindow(typeof(MyEditorWnd)); window.Show(); }