数组定义贴图代码
本代码按F1键动态改变贴图using UnityEngine;
using System.Collections;
public class Test : MonoBehaviour
{
//宣告gameobject
public GameObject ani;
//宣告textureObject物件用來放置貼圖物件
public GameObject textureObject;
//宣告textures陣列用來放置貼圖
public Texture[] textures;
//宣告變數y來變化貼圖
private int y=0;
void Start()
{
}
//用按鍵換圖片
void Update()
{
if (Input.GetKeyDown(KeyCode.F11))
{
y++;
mm(y);
}
}
public void mm(int y)
{
if (y == 1)
{
textureObject.renderer.materials.mainTexture = textures;
}
if (y == 2)
{
textureObject.renderer.materials.mainTexture = textures;
}
if (y == 3)
{
textureObject.renderer.materials.mainTexture = textures;
}
}
} 很不错 好帖就是要顶 顶顶多好 真心顶 不错不错 很不错 楼主是超人 顶顶多好 很好哦