以前こちらで色を変える方法を質問させていただきました。
if文等を用いて現実の指定した時間になったら色をかえるようにしたい(例えば朝の八時になったら赤色にし、九時半になったら青色に戻すといったように考えてます)のですが、その場合どのように組み込めばいいのでしょうか。
using UnityEngine; using System.Collections; using System; public class changeColorScript : MonoBehaviour { public GameObject myCube; // Use this for initialization void Start() { //gameObject取得 myCube = GameObject.Find("Cube"); } // Update is called once per frame void Update () { //今の色コンソールに出力 Debug.Log(myCube.GetComponent<Renderer>().material.color); //時間取得 DateTime dateTime = DateTime.Now; //色の変更 myCube.GetComponent<Renderer>().material.color = Color.blue; //if文を用いて時間によって色が変わるようにする //変更後の色コンソールに出力 Debug.Log(myCube.GetComponent<Renderer>().material.color); } } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/11/06 07:32