AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
CycleColors.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 using UnityEngine;
5 using System.Collections;
6 using System.Collections.Generic;
7 
8 namespace HoloToolkit.Examples.Prototyping
9 {
14  public class CycleColors : CycleArray<Color>
15  {
16  // color to blend to
17  private Color mTargetColor;
18 
19  // the material to change colors
20  private Material mMaterial;
21 
22  // color transition component - used for animation
23  private ColorTransition mColorTransition;
24 
25  protected override void Start()
26  {
27  mColorTransition = TargetObject.GetComponent<ColorTransition>();
28  base.Start();
29  }
30 
35  public override void SetIndex(int index)
36  {
37  base.SetIndex(index);
38 
39  mTargetColor = Array[Index];
40 
41  if (mColorTransition == null)
42  {
43  Renderer renderer = TargetObject.GetComponent<Renderer>();
44 
45  if (renderer != null)
46  {
47  mMaterial = renderer.material;
48  }
49 
50  mMaterial.color = mTargetColor;
51  }
52  else
53  {
54  mColorTransition.StartTransition(mTargetColor);
55  }
56  }
57 
61  private void OnDestroy()
62  {
63  if(mMaterial != null)
64  {
65  GameObject.Destroy(mMaterial);
66  }
67  }
68  }
69 }
override void Start()
set the default values
Definition: CycleColors.cs:25
CycleArray is a class for incrementing through component properties sequentially or assigning specifi...
Definition: CycleArray.cs:15
override void SetIndex(int index)
Select the color from the Array and apply it.
Definition: CycleColors.cs:35
Cycle through a list of colors and apply the current color to the material Supports ColorTransition f...
Definition: CycleColors.cs:14
void StartTransition(Color color, string name="")
Fades the color of a material called by name
A color blending animation component, handles multiple materials