Search Unity

Adding OnGUI event to ScriptableWizard makes button poof!

Discussion in 'Scripting' started by tgraupmann, Apr 9, 2009.

  1. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    I'm putting a script together and have a scripting question about ScriptableWizard.

    I started with this:
    Code (csharp):
    1. [MenuItem("Assets/Save Asset Bundle As Assets")]
    2.     static void CreateWizard()
    3.     {
    4.         ScriptableWizard.DisplayWizard("Save Asset Bundle As Assets", typeof(SaveAssetBundleAsAssets), "Download The Asset Bundle");
    5.     }
    That adds the wizard menu item. And a button is added "Download The Asset Bundle".

    I wanted some input fields on my wizard so I added an OnGUI event.

    Code (csharp):
    1.     void OnGUI()
    2.     {
    3.         EditorGUILayout.LabelField("Asset Bundle URL", string.Empty);
    4.         m_assetBundleURL =
    5.             EditorGUILayout.TextArea(m_assetBundleURL);
    6.     }
    That causes my label and textarea to appear.

    The problem is the button "Download The Asset Bundle" disappears after adding the OnGUI event.

    How do I get the button back?

    Or how do I add a label and textarea while keeping the button?
     
  2. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    It looks like the usual GUI stuff works.

    So GUI.Button works even in an editor script.
     
  3. yoyo

    yoyo

    Joined:
    Apr 16, 2010
    Posts:
    112
    Looks like ScriptableWizard isn't expected to have a custom UI. Note that if you add properties to the wizard (public fields, or private and marked with [SerializeField]) they will show up in the wizard UI. Any time these fields are modified the OnWizardUpdate method will be called.

    But yeah, if you want full control, implement OnGUI and write your own UI from scratch. At which point you might as well just create an EditorWindow, rather than a ScriptableWizard.