1.场景 一个光源, 一个cube1 一个cube2 一个sphere 一个Cylinder
点击cube1 可以控制 光源亮度 cube1变大变小 cube2旋转 sphere颜色 cylander走停
using UnityEngine;
using System.Collections;
public class cude1 : MonoBehaviour {
public static bool aaa=false;
void Start () {
}
void Update () {
if (aaa == true) {
transform.localScale = new Vector3 (2.0F, 2.0F, 2.0F);//改变缩放比例大小
} else {
transform.localScale = new Vector3 (1.0F, 1.0F, 1.0F);
}
}
void OnMouseDown()
{
aaa = !aaa;
}
}
using UnityEngine;
using System.Collections;
public class cude2 : MonoBehaviour {
//public cude1 c1;
public float yRotation = 0.0f;
void Start () {
}
void Update () {
if(cude1.aaa){
yRotation++;
transform.eulerAngles = new Vector3(0, yRotation, 0);//旋转
}
}
}
using UnityEngine;
using