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
3
Question by kiriri · Jun 09, 2014 at 02:59 PM · editorsceneviewupdate problemgizmoondrawgizmos

Constantly Update Scene View

Hey, I'm working on a 2D terrain Engine. If "paint mode" is enabled, I use Gizmos.DrawGUITexture in a OnDrawGizmos funtction to show the brush position in the editor scene view. Of course it's based on the mouse position. However, due to the nature of the scene renderer this guitexture only gets updated when a mouse button or the like is pressed. So if I just move my mouse, functions like OnDrawGizmos or Update do not get called. Coroutines don't work since they are based on Unity's internal framerate.

How can I set a constant frame rate in the editor?

Incase this didn't quite make sense, here's my code :

         void OnDrawGizmos()
         {
                 Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
                 var plane = new Plane(upV, point);
                 float distance;
                 if (plane.Raycast(ray, out distance))
                 {                        
                     var hitPos = ray.origin + distance*ray.direction;
                     Gizmos.DrawGUITexture(new Rect(hitPos.x- brushSize/2f,
                         hitPos.y+brushSize/2f, brushSize, -brushSize),
                         stencils[stencilIndex].texture, gizmoMaterial);
                 }
         }

which only gets called when a button is pressed, not when I just move my mouse.

Any help would be appreciated.

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
7
Best Answer

Answer by Guessmyname · Jan 14, 2015 at 04:57 PM

I had a similar issue; the trick is to use SceneView.RepaintAll and Event.current.

 if(Event.current.type == EventType.MouseMove) SceneView.RepaintAll();

This makes the scene views repaint on mouse move events.

Catch is, this has to be done from Editor code (ie it requires UnityEditor as an include), so you're going to have to use a custom inspector and shift all your painting code into its OnSceneGUI function, I'm afraid.

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

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

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

Related Questions

Mouse click in edit mode. ✱✺✸❁ 1 Answer

What is the best way to fix texture z-fighting? 5 Answers

Permanent handles (when object is not selected) 1 Answer

Select object by selecting gizmo or handle? 1 Answer

Turn scene view "full screen" off 0 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