[RequireComponent(typeof(....))]】的更多相关文章

RequireComponent的使用: 当你添加的一个用了RequireComponent组件的脚本,需要的组件将会自动被添加到game object(游戏物体).这个可以有效的避免组装错误.举个例子一个脚本可能需要刚体总是被添加在相同的game object(游戏物体)上.用RequireComponent属性的话,这个过程将被自动完成,因此你可以永远不会犯组装错误. 用法:在新建的类前面加 [RequireComponent(typeof(Rigidbody))] AddComponent…
using UnityEngine; using System.Collections; [RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))] public class starTest : MonoBehaviour { private Mesh mesh; void Start() { } void Update() { } } 代码是这么写的但是编译完后发现没增加组件, 为啥呢…… 把拖到GameObject上的脚本删了然…
RequireComponent的使用: 当你添加的一个用了RequireComponent组件的脚本,需要的组件将会自动被添加到game object(游戏物体).这个可以有效的避免组装错误.举个例子一个脚本可能需要刚体总是被添加在相同的game object(游戏物体)上.用RequireComponent属性的话,这个过程将被自动完成,因此你可以永远不会犯组装错误. 用法:在新建的类前面加 [RequireComponent(typeof(Rigidbody))] 如图:使用前 AddCo…
Unity中的Inspector面板可以显示的属性包括以下两类:(1)C#以及Unity提供的基础类型:(2)自定义类型,并使用[System.Serializable]关键字序列化,比如: [System.Serializable] public class TestClass { public Vector3 vec = Vector3.zero; public Color clr = Color.green; } 也可以使用[System.NonSerialized]标记不需要显示的属性,…
这个框架是Unity wiki上的框架.网址:http://wiki.unity3d.com/index.php/Finite_State_Machine 这就相当于是“模板”吧,自己写的代码,写啥都是一个风格,还是得多读书,多看报啊... 有限状态机用来做状态转移,比如代码中的例子,NPC有两个状态跟着主角走(状态A),或者沿着自己的路线走(状态B).有两个转换,其实就是两条边,A->B,B->A. 框架里面Transition表示边,StateID表示状态,FSMState是一个状态的抽象…
先上效果. 制作原理:模糊的部分是用UITexture,前面是一个UISprite.用主摄像机渲染出一张纹理,把这张纹理模糊处理,把这张纹理赋值给UITexture. 脚本代码 using UnityEngine; using System.Collections; [RequireComponent(typeof(UITexture))] public class BlurTextureMaker : MonoBehaviour { public int iterations = 3; pub…
线上效果 确保你的纹理的read/write 是勾选的,纹理格式是 RGBA32的 //代码 using UnityEngine; [RequireComponent(typeof(UITexture))] public class ChangeTexturePixel : MonoBehaviour { private UITexture mUITex; private Texture2D MyTex; public int Radius = 10; public Color Col = ne…
最近在学习unity编辑器,so,记录总结一下. 以下介绍了一些简单的unity3d检视面板部分的使用技巧. using UnityEngine; using System.Collections; //让你在将这个脚本拖到一个GameObject上的时候,自动添加Camera,Light,Cloth组件 [RequireComponent(typeof(Camera), typeof(Light), typeof(Cloth))] public class MyClass : MonoBeha…
原文地址:http://www.cnblogs.com/cqgreen/p/3348154.html   一.当下移动设备的主流分辨率(数据来自“腾讯分析移动设备屏幕分辨率分析报告”) 1.1 iOS设备的分辨率主要有:   宽 高 宽高比 960 640 1.5 1136 640 1.775 1024 768 1.3333 2048 1536 1.3333   Android设备的分辨率则相对纷杂,主流的分辨率有: 宽 高 宽高比 800 480 1.6667 854 480 1.7792 1…