Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

ScriptableWizard using Javascript?

Discussion in 'Scripting' started by thylaxene, Jun 28, 2007.

  1. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    Sorry if this a complete unity 101 question. But is it possible to create ScriptableWizards using Javascript? A real basic 'hello world' type of example would be really appreciated. For example how does one use DisplayWizard from within JS? I can see exactly how it is used in C#, but for the life of me I can't get it to work in JS. Yes I would really prefer doing it in JS.

    Cheers.
     
  2. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    It's almost exactly the same as in C#:
    Code (csharp):
    1. //wizards must explicitly declare the class name and extend ScriptableWizard
    2. class WizardExample extends ScriptableWizard {
    3.    
    4.     //wizard variables
    5.     var displayString : String = "Hello!";
    6.    
    7.     //Menu item starts wizard
    8.     @MenuItem ("GameObject/Wizard")
    9.  
    10.     static function MenuItem() {
    11.         ScriptableWizard.DisplayWizard("Title", WizardExample, "Button", "");
    12.     }
    13.     //this is called when you push the button
    14.     function OnWizardCreate() {
    15.         Debug.Log(displayString);
    16.     }
    17. }
     
  3. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    Thanks! I figure it would be almost exactly the same. Its those first 2 lines that I didn't know about. Thanks very much.

    Cheers.
     
  4. covert

    covert

    Joined:
    Nov 29, 2012
    Posts:
    16
    Note that the file name of this example script has to be WizardExample.js.
    And there mustn't be a c# equivalent to that file (i.e.: no WizardExample.cs).