文档库 最新最全的文档下载
当前位置:文档库 › unity3D加载贴图

unity3D加载贴图

using UnityEngine;
using System.Collections;

//public class PicView : MonoBehaviour {
public class PicView
{
//LoadControl_c load;
public Texture2D texture;
public GameObject gameObj;
public GameObject[] objectAll;
public int i = 0;
//public bool isAdd = true;
//10张贴图将会被放入以下10个物体上
public PicView ()
{
objectAll = new GameObject[10];
objectAll [0] = GameObject.Find ("0");
objectAll [1] = GameObject.Find ("1");
objectAll [2] = GameObject.Find ("2");
objectAll [3] = GameObject.Find ("3");
objectAll [4] = GameObject.Find ("4");
objectAll [5] = GameObject.Find ("5");
objectAll [6] = GameObject.Find ("6");
objectAll [7] = GameObject.Find ("7");
objectAll [8] = GameObject.Find ("8");
objectAll [9] = GameObject.Find ("9");

// for(int j = 0; j < objectAll.Length ; j++)
// {
// objectAll[j] = GameObject.Find("j");
// }

}
//适当的位置调用此函数
public void AddPic (Texture texture)
{
gameObj = objectAll [i];
gameObj.renderer.material.SetTexture ("_MainTex", texture);
gameObj.renderer.material.shader = Shader.Find ("Unlit/Transparent");
i++;
}

}

相关文档
相关文档 最新文档