C#のunityについての質問なのですが
Posted: 2014年5月26日(月) 10:18
相談したいのはunity環境の画像切り替えなのですが、Texture内の画像切り替えはどのようにしたらよろしいのでしょうか。
(
using UnityEngine;
using System.Collections;
using UnityEditor;
public class Animal : MonoBehaviour {
private GameObject animal;
private bool state;
private Texture temp;
// Use this for initialization
void Start () {
animal = GameObject.Find("animal");
this.state = false;
this.tmp = renderer.material.mainTexture;
}
public void ChangeState(bool state){
this.state = state;
}
void OnGUI(){
if( this.animal.transform.position.y <= 0 ){
if( GUI.Button(new Rect (50, 50, 100, 100), "Get") )
Application.LoadLevel("test2");
if (renderer.material.mainTexture == temp) {
renderer.material.mainTexture = Instantiate(Resources.Load("画像"));
}
}
}
// Update is called once per frame
void Update () {
if( Input.GetKey( "left" ) == true )
animal.transform.Translate((float)0.005,(float)0.005,(float)0.0);
if( this.state == true )
if( this.animal.transform.position.y >= 0 ){
this.animal.transform.Translate(0f,-0.005f,0.0f);
}
}
}