x


Manually Update/Redraw Scene View?

I have a GameObject whose gizmo is drawn differently depending on certain properties of the GameObject which are modified through a custom editor I've created for it. As it is now, if I modify one of the properties, the gizmo isn't redrawn until I click in the scene view. Is there any way to manually update the either the scene view or just the gizmo when one of the properties is modified?

more ▼

asked Dec 30 '09 at 10:48 PM

Stelimar gravatar image

Stelimar
3k 14 16 50

(comments are locked)
10|3000 characters needed characters left

4 answers: sort voted first

I believe HandleUtility.Repaint does what you want.

more ▼

answered Jan 01 '10 at 02:50 AM

Jaap Kreijkamp gravatar image

Jaap Kreijkamp
6.4k 20 26 70

This only works in the editor. You can not build the project with this code in it. Any other ideas?

Oct 20 '10 at 05:16 PM ClandestineMan

Should be in Editor folder of your scripts as it is editor functionality, you don't have a scene view in final build, so what use would it be to have it compiled in project.

Nov 10 '10 at 03:49 AM Jaap Kreijkamp

It sounds like it should do what the OP wants, but it doesn't seem to work. I have the same issue. HandleUtility.Repaint doesn't refresh my scene view (I'm on Unity 3.3 on a Windows PC).

Sep 07 '11 at 11:19 PM yoyo
(comments are locked)
10|3000 characters needed characters left

You should use this code:

if (GUI.changed) EditorUtility.SetDirty (target);

For more details see the documentation "LookAtPointEditor.js"

more ▼

answered Jan 19 '11 at 07:15 AM

mihapro gravatar image

mihapro
51 1 4

This works although it marks the scene as unsaved. In my case I need to redraw the scene when the user changes the current tool in the inspector, which obviously doesn't make any change to the component itself. But the scene must be redrawn to display a different set of handles. But I guess I can live with it :)

May 05 '11 at 07:51 PM hardwire

+1, this worked for me. Agreed on not liking the dirtying of the scene, but I can also live with it. Has anyone filed a bug report about HandleUtility.Repaint not doing what it seems like it ought to?

Sep 07 '11 at 11:19 PM yoyo
(comments are locked)
10|3000 characters needed characters left

SceneView.RepaintAll(); You can try this, it works for me.

more ▼

answered Mar 07 '12 at 03:57 AM

mbysky gravatar image

mbysky
46 1

Thanks for the snippet! This worked for me as well.

Aug 16 '12 at 08:38 PM donhelms
(comments are locked)
10|3000 characters needed characters left

I just ran into this same question today myself. To further clarify the situation:

I have a series of checkboxes in my inspector that set static variable values to determine which handles to display. My OnSceneGUI() function tests the values of these variables to determine whether it should draw each handle. Though I could confirm these values would update in my OnInspectorGUI() function, I could not confirm they were updating in OnSceneGUI().

In order to make the scene view redraw, I put a call to HandleUtility.Repaint() first thing in my OnSceneGUI() function. I don't know if this is correct or ideal, but it works. I'd be interested to know if there is another way we are supposed to be doing this so I don't force repaint at all times if it is not needed.

more ▼

answered May 06 '10 at 04:21 PM

Adam Mechtley gravatar image

Adam Mechtley
195 8 9 16

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x347
x84
x69

asked: Dec 30 '09 at 10:48 PM

Seen: 5845 times

Last Updated: Aug 16 '12 at 08:38 PM