Subversion Repository Public Repository

Nextrek

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using UnityEngine;
using System.Collections;

public class armor : MonoBehaviour
{
	//An array of Objects that stores the results of the Resources.LoadAll() method
	private Object[] objects;
	//Each returned object is converted to a Texture and stored in this array
	private Texture[] textures;
	//With this Material object, a reference to the game object Material can be stored
	private Material goMaterial;
	//An integer to advance frames
	private int frameCounter = 0;	
	private float a=1; //alpha control
	public static float armor_=100;
	
	void Awake()
	{
		//Get a reference to the Material of the game object this script is attached to
		this.goMaterial = this.GetComponent<Renderer>().material;
		this.GetComponent<Renderer>().material.color = new Color(this.GetComponent<Renderer>().material.color.r,this.GetComponent<Renderer>().material.color.b,this.GetComponent<Renderer>().material.color.g,.65f*a);
	}

	void Start ()
	{

		//Load all textures found on the Sequence folder, that is placed inside the resources folder
		this.objects = Resources.LoadAll("Holographic/output/main/armor", typeof(Texture));

		//Initialize the array of textures with the same size as the objects array
		this.textures = new Texture[objects.Length];

		//Cast each Object to Texture and store the result inside the Textures array
		for(int i=0; i < objects.Length;i++)
		{
			this.textures[i] = (Texture)this.objects[i];
		}
	}
	
	
	void OnGUI () {
		}

	void Update ()
	{
		frameCounter=(int)Mathf.Round((100f-armor_)/5.263f);
		goMaterial.mainTexture = textures[frameCounter];

	}

  

}

Commits for Nextrek/3DSpace/Assets/Resources/Holographic/Scripts/armor.cs

Diff revisions: vs.
Revision Author Commited Message
168 Diff Diff LMancini picture LMancini Wed 08 Apr, 2015 12:33:35 +0000
112 Diff Diff FMMortaroli picture FMMortaroli Thu 09 Oct, 2014 14:21:59 +0000
107 FMMortaroli picture FMMortaroli Thu 09 Oct, 2014 11:56:46 +0000