Tanoda
SimpleInteractionEmission.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
10using System.Collections;
11using System.Collections.Generic;
12using UnityEngine;
13
14namespace Leap.Unity.Examples {
15
16 [AddComponentMenu("")]
17 [RequireComponent(typeof(InteractionBehaviour))]
18 public class SimpleInteractionEmission : MonoBehaviour {
19
22
23 private Material _material;
24 private int _emissionColorId;
25
26 private InteractionBehaviour _intObj;
27
28 private Color _targetColor;
29
30 void Start() {
31 var renderer = GetComponentInChildren<Renderer>();
32 if (renderer != null) {
33 _material = renderer.material;
34 _emissionColorId = Shader.PropertyToID("_EmissionColor");
35 }
36
37 _intObj = GetComponent<InteractionBehaviour>();
38 }
39
40 void Update() {
41 _targetColor = nonPrimaryHoverEmission;
42
43 if (_intObj.isPrimaryHovered) {
44 _targetColor = primaryHoverEmission;
45 }
46
47 _material.SetColor(_emissionColorId, Color.Lerp(_material.GetColor(_emissionColorId), _targetColor, 20F * Time.deltaTime));
48 }
49
50 }
51
52}
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.