Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by reptilebeats · Jul 30, 2012 at 05:54 PM · javascripteditor

open a editor window in javascript

hi i would like to know how to open an editor window in javaScript/UnityScript, I've made a couple components in csharp but what ever i try i can't seem to get the window to open in java.

and yes my script is in the editor folder and here is what i was looking at but doesn't seem to work

 // JavaScript example:
 class MyWindow extends EditorWindow {
     var myString = "Hello World";
     var groupEnabled = false;
     var myBool = true;
     var myFloat = 1.23;
     
     // Add menu named "My Window" to the Window menu
     @MenuItem ("Window/My Window")
     static function Init () {
         // Get existing open window or if none, make a new one:        
         var window = ScriptableObject.CreateInstance.<MyWindow>();
     }
     
     function OnGUI () {
         GUILayout.Label ("Base Settings", EditorStyles.boldLabel);
             myString = EditorGUILayout.TextField ("Text Field", myString);
         
         groupEnabled = EditorGUILayout.BeginToggleGroup ("Optional Settings", groupEnabled);
             myBool = EditorGUILayout.Toggle ("Toggle", myBool);
             myFloat = EditorGUILayout.Slider ("Slider", myFloat, -3, 3);
         EditorGUILayout.EndToggleGroup ();
     }
 }
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Eric5h5 · Jul 30, 2012 at 06:07 PM 2
Share

Unity does not use Java. Also it's better to post web links, not links to files on your computer.

avatar image reptilebeats · Jul 30, 2012 at 06:14 PM 0
Share

whoops i didn't realise i just copy and pasted the link from safari, ill change it

avatar image Ash-Blue · Sep 11, 2013 at 06:32 AM 0
Share

Please note that this example is broken, you'll need to modify the script with the following example http://docs.unity3d.com/Documentation/ScriptReference/EditorWindow.GetWindow.html

1 Reply

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by flamy · Jul 30, 2012 at 07:25 PM

 // Add menu named &quot;My Window&quot; to the Window menu
     @MenuItem ("Window/My Window")
     static function Init () {
         // Get existing open window or if none, make a new one:        
         var window : MyWindow  = ScriptableObject.CreateInstance.<MyWindow>();
 
         window.Show();
     }

did you try calling the function show?? the window wont be shown in js unless this is called. but in c# it will be automatically shown on using GetWindow function. IDK for some reason they didnt give it clearly in the editor window example for js.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image reptilebeats · Jul 30, 2012 at 09:05 PM 0
Share

got it thanks, so i have to state to show the window, i thought the create instance would of done this, thanks i will test it out and hopefully get it working

avatar image reptilebeats · Jul 30, 2012 at 09:08 PM 0
Share

sweet works now, they should update their reference to say this annoying for learners like me

avatar image flamy · Jul 31, 2012 at 02:08 AM 0
Share

even i suffered for like 4 or 5 hours previously... but got tht somehow by luck!! :P

avatar image Bunny83 · Jul 31, 2012 at 03:09 AM 1
Share

Well the problem is they did update the docs ;) The Unityscript example is new and wrong / or not complete. The C# example still uses EditorWindow.GetWindow which searches for the first instance of that type or, if there is none, it created an instance and automatically shows the window.

CreateInstance just creates an instance of a ScriptableObject or EditorWindow (which is derived from ScriptableObject). If there is already an instance, CreateInstance will create another one. You have to show the window manually. This allows you to show the EditorWindow with a different style ( ShowUtility, ShowPopup, ShowAuxWindow, Show)

avatar image reptilebeats · Jul 31, 2012 at 03:26 AM 0
Share

Ahh ok i think i might have to get some books on coding especially for unity, the internet just pulls up all sorts of wrong information, but then how are you supposed to google something if you dont know what the thing your looking for is called.

Cheers for explaning it

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

scripting problems with editorGUI 1 Answer

Time.deltaTime in Editor script 2 Answers

MetaData class can't be loaded and failed to load window layout 1 Answer

Edit terrain using js 1 Answer

Can someone help me fix my Javascript for Flickering Light? 6 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges