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
0
Question by Scud · May 31, 2013 at 05:58 PM · editoronscenegui

Interaction with scene view in editmode?

Trying to create editor, that capable of drawing texture on my tiled mesh. I can do that in runtime, but completely can't understand editmode. Using Javascript, expect to receive "working" in the console on mousedown in sceneview... How can I do that?

 #pragma strict
 //using UnityEditor;
 //@script ExecuteInEditMode()
 
 class HexMaker extends EditorWindow {
 
     @MenuItem ("Window/HexMaker")
     static function ShowWindow () {
     EditorWindow.GetWindow (HexMaker);
     }
 
     function OnGUI () {
     }
       
     function OnSceneGUI () {
         if (Event.current.type == EventType.MouseDown){
             Debug.Log("working");
             //  Event.current.Use();
         }
     }  
 }
  



  
Comment
Add comment
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

1 Reply

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

Answer by numberkruncher · May 31, 2013 at 06:06 PM

EditorWindow's do not support the OnSceneGUI message.

Instead you will need a custom `Editor` in order to achieve this. Here is a simple example of a custom editor:

 #pragma strict
 @CustomEditor(MyPlayer)
 class MyPlayerEditor extends Editor {

     function OnSceneGUI() {
         if (Event.current.type == EventType.MouseDown) {
             Debug.Log("TEST");
         }
     }

 }

The above example works with a custom MonoBehaviour script called MyPlayer. This will only work when a game object with "MyPlayer" attached is selected.

Example video: (please excuse my Autocomplete nightmare in MonoDevelop, I don't usually use it for coding!) http://www.youtube.com/watch?v=QG-_sbCP4iA

Comment
Add comment · Show 6 · 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 numberkruncher · May 31, 2013 at 06:33 PM 0
Share

I have added a simple example to my answer for you with a little clarification.

avatar image numberkruncher · May 31, 2013 at 06:34 PM 0
Share

Also, you may find the following forum thread of use: http://forum.unity3d.com/threads/34137-SOLVED-Custom-Editor-OnSceneGUI-Scripting

avatar image Scud · May 31, 2013 at 06:54 PM 0
Share

Thank you for finding this thread, but i wanna the same in JS. Done two tutorials, from which achieve the desired, but both of them in C#, and for now I can't understand C#. Can't compile your example: $$anonymous$$ Identifier "$$anonymous$$yPlayer". Yes, script is named $$anonymous$$yPlayer. You tell that script working when GO selected? Can't attach script to GO, "script needs to derive from $$anonymous$$onoBehaviour"

avatar image numberkruncher · May 31, 2013 at 07:32 PM 0
Share

Here is the demo video: http://www.youtube.com/watch?v=QG-_sbCP4iA

avatar image Scud · May 31, 2013 at 08:02 PM 0
Share

It's working now! Thank you a lot! So, i need GO $$anonymous$$yPlayer, to add Debug.Log to his custom inspector from editor script... Confusing) Wonder, why I need GO still? Is Rotorz Tile System have to use GridPlane GO as $$anonymous$$yPlayer in your example? btw I excited with Rotorz tile painting tool) Sorry for my English)))

Show more comments

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

15 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

GUI & GUILayout methods no longer work in OnSceneGUI() 1 Answer

Scripting a Click event in the Unity Editor 1 Answer

Adding drag function to a polygon editor 1 Answer

How can you access the Game screen and its properties from an Editor Script? 1 Answer

How to read the current PivotRotation or PivotMode ? 1 Answer


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