Unity3D에서 텍스쳐 바꿔치기 하는 방법
Unity3D 2012. 9. 25. 17:16
using UnityEngine;
using System.Collections;
public class Main : MonoBehaviour
{
public GameObject prefab;
private GameObject go;
private bool flip;
// Use this for initialization
void Start()
{
flip = false;
go = Instantiate(prefab) as GameObject;
go.transform.position = new Vector3(0, 0, 0);
go.animation.wrapMode = WrapMode.Loop;
}
// Update is called once per frame
void Update()
{
if (Input.GetButtonUp("ChangeTexture"))
{
Debug.Log("Change Texture Button Up");
int count = 0;
if (flip)
{
flip = false;
Debug.Log("Set Texture bytesTexture");
foreach (SkinnedMeshRenderer smr
in go.GetComponentsInChildren<SkinnedMeshRenderer>(true))
{
smr.material.SetTexture(
"_MainTex",
Resources.Load("bytesTexture") as Texture);
count++;
}
}
else
{
flip = true;
Debug.Log("Set Texture fuelCellTexture");
foreach (SkinnedMeshRenderer smr
in go.GetComponentsInChildren<SkinnedMeshRenderer>(true))
{
smr.material.SetTexture(
"_MainTex",
Resources.Load("fuelCellTexture") as Texture);
count++;
}
}
Debug.Log("smr count is " + count);
}
}
}
'Unity3D' 카테고리의 다른 글
NGUI 한글 멘붕 (2) | 2012.09.27 |
---|---|
Tile Mapper (0) | 2012.09.26 |
Game Asset Website List (Free and Paid) (Textures, Models, Packs, etc) (0) | 2012.09.25 |
[Unity3D] Attributes 설명 모음 (2) | 2012.09.25 |
Unity3D로 풀3D web mmorpg 만들기 (0) | 2012.09.24 |