RSS

Tag Archives: event handler

Unity: Detect GUI Window Created/Closed Event


On StackOverflow, someone asks how to detect the GUI Window Created/Closed Event, which Unity3D does not ship an off-the-shelf solution.

Below is my solution to this problem: to use property setter to handle this. Here is the sample code:

enter image description here

Read the rest of this entry »

Advertisements
 
Leave a comment

Posted by on June 11, 2015 in Programming, Unity 3d

 

Tags: , , , , , , , , , , , ,

Unity3D: inspector control value changed event handling


Unity3D has offered very handy interface to expose variables so that users can edit them in inspector. Take a look at below snapshot: one can define some public fields, and these fields are immediately seen in the inspector, once the script is attached tom some game object:

image  image

That is cool! But you might expect another feature: when the value changes, you get notified, and can hook your own action with it!

In C# and winform, it is trivial: SomVarTextBoxControl.TextChanged += YourAction(…)

Unfortunately, this kind of handy event handler does not exist in Unity3D! To get similar functionality, you need use custom editor!

Read the rest of this entry »

 
1 Comment

Posted by on January 11, 2014 in Programming, Unity 3d

 

Tags: , , , , , , , ,