unity->C#->组件->点击cube1 可以控制 光源亮度 cube1变大变小 cube2旋转 sphere颜色 cylander走停
2015-03-10 08:43
1146 查看
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 System.Collections; public class cylinder : MonoBehaviour { // Use this for initialization void Start () { } void Update () { if (cude1.aaa) { this.transform.Translate (0.1f, 0, 0, Space.World);//x轴方向移动 } else { this.transform.Translate (-0.1f, 0, 0, Space.World); } } }
using UnityEngine; using System.Collections; public class light : MonoBehaviour { public float a=0.0f; void Start () { } void Update () { if (cude1.aaa) { if (a < 8.0f) { a = a + 0.1f; this.gameObject.GetComponent<Light> ().intensity = a;//光照强度修改 } else { a = 0.0f; this.gameObject.GetComponent<Light> ().intensity = a; } } } }
using UnityEngine; using System.Collections; public class color : MonoBehaviour { private MeshRenderer mm; void Start () { mm = this.gameObject.GetComponent<MeshRenderer> ();//mm代表材质球 } void Update () { if (cude1.aaa) { mm.material.color = new Color (0, 1, 0); } else { mm.material.color = new Color (1, 1, 0); } } }
相关文章推荐
- BootStrap3 笔记(一):关于分页组件中<a>标签disable后还是可以点击的问题
- css相关,鼠标点击<input>输入域后出现有颜色的边框
- .NET C#生成随机颜色,可以控制亮度,生成暗色或者亮色 基于YUV模式判断颜色明亮度
- BootStrap学习笔记(二):关于分页组件中<a>标签disable后还是可以点击的问题
- <Unity UGUI><EasyTouch> 使用EasyTouch, 摇杆在Dynamic模式下,点击UI控件也会弹出的问题解决
- 布局可以写到最外层的超级组件----->
- 面向组件编程之Unity 7.怎样脚本控制物体旋转和移动 关键字:画圆&&Translate/transform.Translate,transform.Rotate
- SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 s
- 只有EXE软件加上网络超链接-------->广告点击------->好的网络游戏广告是充值的----->整个广告权算帐
- Excel之【保护工作表】功能(工具---->保护) ------可以防止修改格式,删除行。只能在里面填写数据。
- G1->I7500->G2,手机原来可以这么有趣
- vc 下可以运行在设置项Project->Settings->Debug->Program arguments填参数
- 一个正整数有可能可以被表示为n(n>=2)个连续正整数之和--算法求解
- 指针在任何情况下都可以进行>,=,<=, ==运算
- 经典的图片无缝滚动,点击向上向下按钮还可以控制方向
- 组件和控件---- > 控件是组件的一个主要样本体, 组件主要解决的是"复用" ,
- SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 s
- Collection -> .Net集合类型大全,只要灵活运用可以节省很多开发时间和提高程序运行效率
- &lt;展现C#&gt;第八章用C#写组件
- .net开源我也开&amp;gt;&amp;gt;C#远程控制软件整个项目代码发布