Unity3D的脚本属性用法:

// JavaScript@script
AddComponentMenu ("Transform/Follow Transform")
// CSharp
[AddComponentMenu("Transform/Follow Transform")]

以下是具体说明(部分无关紧要的不翻译):

AddComponentMenu(函数)

允许你从其他的"Components"菜单途径添加脚本(如果不使用AddComponentMenu那么你只能从Components->Scripts下添加)。注意需restart起效。

ContextMenu

允许为脚本增加一组命令,该属性标记在函数上,而且必须是non-static函数。
假设你为一个脚本move增加了一个ContextMenu属性的方法Do somethine,该方法作用是Debug.Log。这个move脚本attach在一个user身上。那么你选中user时,在inspector面板中对move component右击,就会发现一组命令,点击打印。
这个属性一个有用之处是自动初始化。

ImageEffectOpaque

Any Image Effect with this attribute will be rendered after opaque geometry but before transparent geometry.

This allows for effects which extensively use the depth buffer (SSAO ect) to only affect opaque pixels. This Attribute can be used to reduce the amount of visual artifacts in a scene with post processing.

ImageEffectTransformsToLDR

When using HDR rendering it can sometime be desirable to switch to LDR rendering during ImageEffect rendering.

Using this Attribute on an image effect will cause the destination buffer to be an LDR buffer, and switch the rest of the Image Effect pipeline into LDR mode. It is the responsibility of the Image Effect that this Attribute is associated to ensure that the output is in the LDR range.

ExecuteInEditMode

默认脚本组件仅在play mode下执行。增加这组属性后,脚本的callback functions在eidtor下亦可执行。注意,调用频率不同于 Play Mode:
Update只发生在Scene中的一些东西变更。
OnGUI只发生在Game View收获到一组事件。
OnRenderObject以及其他渲染事件只发生在Scene View or Game View 的 repaint 中。

HideInInspector

设置一个变量,不显示在inspector面板,但是  be serialized。

NonSerialized

让一个变量不要 serialized,这样的话你可以保持一个公共变量,但是不显示在inspector面板且不尝试 serialize(即你改动之,下次开启的话仍然是你申明的初始值)。

NotConvertedAttribute

Instructs the build pipeline not to convert a type or member to the target platform。

NotRenamedAttribute

Prevent name mangling of constructors, methods, fields and properties.

When applied to a type prevents all its members of being renamed.

It can be used to provide stable member names for access from handwritten ActionScript code or to provide .net stubs for ActionScript types when combined with NotRenamedAttribute

RPC

制定一个函数RPC属性,这个方法可以通过Unity Networking来远程访问。该函数必须eixst on both sending and recieving party

RequireComponent

指明自动增加对应的依赖component。例如:
[RequireComponent (typeof (Rigidbody))]
public class PlayerScript : MonoBehaviour {void FixedUpdate()  {rigidbody.AddForce(Vector3.up);}
}

Serializable

申明这个属性的class,其内部属性可以通过inspector面板访问到。例如:Vector3这样的东东。

SerializeField

申明一个private变量需要序列化(serialize),正常情况下你不应该需要到这个属性。
注意,serialize是指当你在inspector面板改动一个值时,unity editor会自动记录你的变更。这样你重新开启工程时,unity构建世界时自动使用你上次的值。

Unity3D脚本属性相关推荐

  1. Unity3D脚本中文系列教程(七)

    http://dong2008hong.blog.163.com/blog/static/4696882720140311445677/?suggestedreading&wumii Unit ...

  2. Unity3D脚本中文系列教程(五)

    http://dong2008hong.blog.163.com/blog/static/4696882720140302848544/?suggestedreading&wumii Unit ...

  3. Unity3d 脚本开发代码规范

    代码规范 代码规范问题是这样的一个问题:高性价比,不被重视,实际做的时候难以做好 统一的规范有利于代码简洁,进而利于控制复杂度,关于复杂度可以参见之前的文章(http://blog.csdn.net/ ...

  4. unity3d 脚本参考-技术文档

    unity3d 脚本参考-技术文档 核心提示:一.脚本概览这是一个关于Unity内部脚本如何工作的简单概览.Unity内部的脚本,是通过附加自定义脚本对象到游戏物体组成的.在脚本对象内部不同志的函数被 ...

  5. Unity3D——脚本编程

    在本章中我们将学习的是Unity3D的脚本编程,Unity3d目前支持javascript,c#,Boo这三种脚本的开发!由于本人开发过C++所以就直接用C#来进行unity3d的脚本开发!在脚本开发 ...

  6. (四)unity3D脚本的执行顺序

    一个unity3D脚本的执行顺序: 1. 调用所有Awake方法 2. 调用所有Start方法 3. 游戏逻辑循环(物理部分): 1)调用FixedUp方法 2)物理模拟 3)OnEnter.Exit ...

  7. Unity3D脚本中文系列教程(八)

    ◆ static var matrix : Matrix4x4 描述:设置用于渲染所有gizmos的矩阵. 类方法 ◆ Static function DrawCube(center:Vector3, ...

  8. Unity3D脚本中文教程(八)

    http://blog.sina.com.cn/s/blog_4ef78af50100xhc6.html ◆ static var matrix : Matrix4x4 描述:设置用于渲染所有gizm ...

  9. unity3d脚本获取地图

    最近在做u3d的地图开发,记录一些笔记. unity3d中的地图是terrain,经常需要通过脚本控制地图.但资料很少,甚至不知道各个属性是什么意思.这里说一下用法. unity3d里已经预制了地图t ...

最新文章

  1. Unable to inject views for BcFragment{8d4c0 #1 id=0x7f0d00a1}
  2. python函数的作用是_Python函数一
  3. 关于Ubuntu下面的 完全删除卸载说明
  4. @Async的使用、原理及使用时可能导致的问题
  5. 每一种创伤,都是一种成熟
  6. 全球最难翻译的十大单词
  7. Linux CentOS 6.x设置静态IP(亲测有效)
  8. vscode python环境_在vscode中配置python环境
  9. python基础技巧总结(三)
  10. 重识 SQLite,简约不简单
  11. java连接mysql数据库 R,java连接MySql数据库!
  12. java计算器用什么布局_求JAVA语言写的计算器的代码。用GridLayout布局。
  13. 九度OJ 1060:完数VS盈数 (数字特性)
  14. python对象、引用
  15. 给影像添加alpha通道(透明度)
  16. map的put 方法的返回值 null
  17. 全网最全精析破解 Springboot+Jpa 对数据库增删改查
  18. 函数极限:函数极限的多种形式
  19. 失眠脑子一直在想事情,试试这些高质量睡眠小妙招
  20. T560和为k的子数组

热门文章

  1. 华为畅享8的悬浮窗在哪里_华为畅享8悬浮球设置 | 手游网游页游攻略大全
  2. 惠普z840工作站linux,全模块战神 惠普旗舰级Z840工作站评测
  3. 刚过国家线计算机考研报哪个好,考研估分刚过了去年国家线,今年上岸还有希望吗?有!...
  4. linux做预警机制,预警通告:Linux内核中TCP SACK机制远程DoS
  5. Android 活动与活动间数据传递
  6. 值传递 和 地址传递 的区别(好多句话才可以说清)
  7. app、H5、safari、appstore应用主页评分页之间拉起调用、打开手机某些系统功能、app打开文档
  8. js把for循环出来的数据存入数组
  9. 快速构建Spring Cloud工程
  10. 顺序结构,判断结构 if,switch