前提・実現したいこと
cubeのmaterialを黒から白にスペースキーで変更したいのですができません
発生している問題・エラーメッセージ
エラーは出ていません。
黒から透明はできるのですが白色にできません。
該当のソースコード
C#
1using UnityEngine; 2using System.Collections; 3using UnityEngine; 4public class shoudo : MonoBehaviour 5{ 6 public Material[] _material; // 割り当てるマテリアル. 7 private int i; 8 // Use this for initialization 9 void Start() 10 { 11 i = 0; 12 } 13 // Update is called once per frame 14 void Update() 15 { 16 if (Input.GetKeyUp(KeyCode.Space)) 17 { 18 i++; 19 if (i == 2) 20 { 21 i = 0; 22 } 23 this.GetComponent<Renderer>().material = _material[i]; 24 } 25 } 26} 27
試したこと
materialの部分をcubeにしてみてcube自体の変更も考えましたがコードがかけず断念しました。
。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/19 10:49
2018/12/20 04:13