(1)オブジェクトを手動で回転させる
(スクリプト)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Box : MonoBehaviour
{
void Update()
{
transform.Rotate(new Vector3(0, Input.GetAxis("Mouse X") * 1.5f, Input.GetAxis("Mouse Y")));
}
}
(1)オブジェクトのカラーをボタンで変更する
(スクリプト)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Box : MonoBehaviour
{
public Material[] colors;
void Update()
{
transform.Rotate(new Vector3(0, Input.GetAxis("Mouse X") * 1.5f, Input.GetAxis("Mouse Y")));
}
public void OnRedColorButtonClicked()
{
this.gameObject.GetComponent<MeshRenderer>().material = colors[0];
}
public void OnBlueColorButtonClicked()
{
this.gameObject.GetComponent<MeshRenderer>().material = colors[1];
}
public void OnGreenColorButtonClicked()
{
this.gameObject.GetComponent<MeshRenderer>().material = colors[2];
}
}
(設定)
(実行結果)