Tanoda
TestInteractionStateColor.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using UnityEngine;
10
12
13 [AddComponentMenu("")]
14 public class TestInteractionStateColor : MonoBehaviour {
15
17
18 private Material _mat;
19
20 void Start() {
21 if (intObj == null) {
22 intObj = GetComponent<InteractionBehaviour>();
23 }
24
25 _mat = intObj.GetComponentInChildren<Renderer>().material;
26 }
27
28 void Update() {
29 if (_mat != null && intObj != null) {
30 Color color = Color.white;
31
32 if (intObj.isGrasped) {
33 color = Color.green;
34 }
35 else if (intObj.isPrimaryHovered) {
36 color = Color.blue;
37 }
38 else if (intObj.isHovered) {
39 color = Color.cyan;
40 }
41 else if (intObj.isSuspended) {
42 color = Color.red;
43 }
44
45 var intButton = intObj as InteractionButton;
46 if (intButton != null) {
47 if (intButton.isPressed) {
48 color = Color.yellow;
49 }
50 }
51
52 _mat.color = color;
53 }
54 }
55
56 }
57
58}
UnityEngine.Color Color
Definition: TestScript.cs:32
InteractionBehaviours are components that enable GameObjects to interact with interaction controllers...
bool isPrimaryHovered
Gets whether this object is the primary hover for any interaction controller.
bool isSuspended
Gets whether the object is currently suspended. An object is "suspended" if it is currently grasped b...
bool isGrasped
Gets whether this object is grasped by any interaction controller.
bool isHovered
Gets whether any interaction controller is nearby.