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 StephanK · May 03, 2013 at 12:43 PM · editorgameview

How to manually update GameView?

I have an inspector script that modifies a Bounds value of a MonoBehaviour. That MonoBehaviour also has a OnDrawGizmosSelected that draws a rectangle based on that Bounds value. For convenience I would like to modify the value while looking at the GameView and seeing the results of the update immediately. However, while the value is being updated correctly the rectangle in GameView is not updated until I focus the gameview by clicking on it. Is there a way to force the GameView to update (or force OnDrawGizmosSelected)? I know how to do it using the scene view and that works fine, but I'd like to see it in the GameView.

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

3 Replies

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

Answer by Majnun · Jan 13, 2014 at 04:13 AM

Found this solution after scouring the internet. Doesn't seem well documented at all, so not sure how reliable it will be in the future. Works for me with 4.3.2 with case I was having trouble with (GameView not updating after I changed an object with a custom Editor Window).

 UnityEditorInternal.InternalEditorUtility.RepaintAllViews()
Comment
Add comment · Show 1 · 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 Drakulo · Dec 29, 2014 at 10:12 AM 0
Share

This solution works very well, thanks !

avatar image
1

Answer by Zebibto · Aug 15, 2013 at 02:03 PM

To get a reference to the GameView :

 System.Reflection.Assembly assembly = typeof(UnityEditor.EditorWindow).Assembly;
 Type type = assembly.GetType(name);
 EditorWindow gameview = EditorWindow.GetWindow(type);

Then simply call:

 gameview.Repaint();

This works for me in Unity 4.2.0, but I'm not sure why you can't just use UnityEitor.GameView directly. Other examples I found seem to be able to do this.

Comment
Add comment · Show 2 · 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 Loius · Aug 15, 2013 at 02:25 PM 0
Share

Also see http://answers.unity3d.com/questions/9574/manually-updateredraw-scene-view.html

Related, but not sure if that redraws the game view.

avatar image Oliver Eberlei · Sep 22, 2013 at 04:15 PM 0
Share

Just in case anybody is finding this helpful. The variable name in the second line should be replaced by this

 System.Type type = assembly.GetType( "UnityEditor.GameView" );
avatar image
0

Answer by pctroll · Dec 29, 2013 at 06:37 PM

So, wrapping-up all the answers and comments, this is the definite answer to the question.

 System.Reflection.Assembly assembly = typeof(UnityEditor.EditorWindow).Assembly;
 System.Type type = assembly.GetType( "UnityEditor.GameView" );
 EditorWindow gameview = EditorWindow.GetWindow(type);
 gameview.Repaint();
Comment
Add comment · Show 1 · 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 Steven-1 · Apr 23, 2017 at 03:01 PM 0
Share

This works, however, it causes the inputfields (like EditorGUILayout.FloatField()) to become uneditable, so they become useless. Any way around that?

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

18 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

Related Questions

Add and Select Game View Resolution Programatically 5 Answers

ReadPixels to capture GameView in EditMode and "Pixels out of bounds" 3 Answers

Game object is visible in scene tab,but not in the game tab. 17 Answers

Stepping through WaitForEndOfFrame when GameView isn't visible 1 Answer

GameView reduced to a reasonable size for this system 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