OnFocusEvent component

TheOnFocusEvent component is set up to handle our gaze. It has two modes: Focus Enter and Focus Lost. Here, we will need to add the component and then set up our object to work with it. 

Click on Add Component in the inspector on the LeftRect object. Type in OnFocusEnter and select the OnFocusEnter component:

When the OnFocusEnter component appears, you will see two boxes with plus and minus signs under them. Click on the plus sign for each box:

Now you will see two boxes appear, looking for GameObjects. Simply drag the LeftRect object from the Hierarchy view and drop it into each of these empty fields:

Now, in our ChangeRectColor script, we have two methods to work with these two events: OnGazeRectStart() and OnGazeRectExit()

Click on the top bar labeled No Function, select ChangeRectColor, and then OnGazeRectStart():

Click on the lower bar labeled No Function, select ChangeRectColor, and then OnGazeRectExit():

Now follow steps 1 - 7 on the RightRect object as well. 

Now if you hit the play button in Unity, right-click and move the view around. You should see the object change colors as your cursor moves over them. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.59.187