http://blog.sina.com.cn/s/blog_5b6cb9500101857b.html

Attributes属性属于U3D的RunTimeClass,所以加上下面的命名空间是必须的了。

其他倒没什么须要注意的。

本文将全部执行属性过一遍罢了。

using UnityEngine;
using System.Collections;

1.AddComponentMenu 加入组件菜单
这函数仅仅是起方便用,原本的脚本(组建)都会在“Component/Script”菜单下,在类之前声明一下这个,它便能够出如今"Componet"菜单下的不论什么位置。说明指的是要重新启动U3D才干显示,只是測试貌似直接能够显示。

[AddComponentMenu("MyPhysic/PhysicType")]
public class PhysicType: MonoBehaviour
{
}

2.ContextMenu 上下文菜单
这个译名我认为非常不自然,事实上上下文算是啥东西……这个函数是在Inspector的脚本中加一个触发事件,就是删除脚本重置脚本button的那个小拉菜单中,详细非常难说清位置。所以我截了个图。

public class Attributes : MonoBehaviour {
    [ContextMenu("Hello World!")]
    void HelloWorld()    
    {
        Debug.Log("Hello World!");
    }   
}



3.ExecuteInEditMode 在Editor模式下执行
跟名字一样,在编辑器中执行。只是有三种函数的调用方式。

a- "Update()" is only called when something in the scene changed.
b- "OnGUI()" is called when the Game View recieves an Event.
c- "OnRenderObject()" and the other rendering callback functions are called on every repaint of the Scene View or Game View.

[ExecuteInEditMode]
public class ExecuteInEditModeTest: MonoBehaviour
{
    private Vector3 vec_Rotation = new Vector3(0.0f, 0.5f, 0.0f);
    //Rotate all the time
    void OnRenderObject()
    {
        transform.Rotate(vec_Rotation);
    }
}

4.HideInInspector 在检视面板中隐藏
public class HideInspectorTest : MonoBehaviour 
{
    
    [HideInInspector]

    public Transform m_Target;
    void Start()
    {
        m_Target = GameObject.Find("test").transform;
    }

}

5.RequireComponent 必需要有对应的组建
增加一个组建之前必须存在还有一个对应的组建,若没有则自己主动创建。这个在项目中很有必要用到,尤其是项目人员比較多的时候(大于三四个)。

[RequireComponent (typeof (Rigidbody))]
public class RequireComponentTest : MonoBehaviour {
    void FixedUpdate()  {
        rigidbody.AddForce(Vector3.up);
    }
}

6.NonSerialized 不被序列化
不被序列化该变量,且不显示在检视面板中。
public class Test {
    [System.NonSerialized]
    public int i_Helloword = 5;
}

7.Serializable 可序列化
这个属性能够让子类(继承类)的变量属性显示在检视面板中,也能序列化它。(JS的话全然不须要这个属性。)
//SerializableTest.cs
[System.Serializable]
public class SerializableTest
{
    public int p = 5;
    public Color c = Color.white;
}

//SerializableTest2.cs
public class SerializableTest2 : MonoBehaviour
{
    public SerializableTest test;

}




8.SerializeField 序列化域(强制序列化)
这里写得比較清楚。能够将私有变量序列化,将U3D的内建变量序列化等。

http://game.ceeger.com/Script/Attributes/SerializeField.html

以下的ATTRIBUTE属性预计是没什么人用的了,我也没怎么用过。

1.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.
没用过这玩意。只是应该非常少用得到,优化加速渲染。


2.ImageEffectTransformsToLDR 
也没用过这玩意,LDR应该是某种载入方式。

高动态光照渲染(High-Dynamic Range,简称HDR)。

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.

3.NotConvertedAttribute 不转换属性
我认为这个应该是没有人用的……打包资源的时候,不将成员或类型转换到对应平台,不是非常理解这是干嘛的。

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


4.NotFlashValidatedAttribute 不同意转换到FLASH平台
又是个没人用的东西吧?
Instructs the build pipeline not to try and validate a type or member for the flash platform.

5.NotRenamedAttribute 不同意属性更名
……

6.PropertyAttribute 財产属性?搞不懂
也不知道用来做啥的。


7.PRC
外观似随着NETWORK相关,U3D的NETWORK浮沫,是否。

Unity3d该物业(Attributes)整理的更多相关文章

  1. (转载)Unity3d中的属性(Attributes)整理

    附加: float字段检视面板修改:[Range(1,10)] 对属性进行分组:[Header("xxx")] 工具栏中调用方法,类文件需在Editor文件夹中:[MenuIte( ...

  2. (转)Unity3d中的属性(Attributes)整理

    Attributes属性属于U3D的RunTimeClass,所以加上以下的命名空间是必须的了.其它倒没什么需要注意的.本文将所有运行属性过一遍罢了. using UnityEngine; using ...

  3. Unity3d中的属性(Attributes)整理

    Attributes属性属于U3D的RunTimeClass,所以加上以下的命名空间是必须的了.其它倒没什么需要注意的.本文将所有运行属性过一遍罢了. using UnityEngine; using ...

  4. Unity3D 学习——入门资料整理

    感觉可以写3D游戏,还是用C#,很好玩的样子.整理最近学习资料 介绍:游戏引擎,可以用C#配置的游戏引擎.嗯,就这样.其余度娘. 安装:官网,因为现在个人版是免费的.直接官网下.干净利落. 调试插件: ...

  5. Unity3D性能优化--- 收集整理的一堆

    http://www.cnblogs.com/willbin/p/3389837.html 官方优化文档--优化图像性能http://docs.unity3d.com/Documentation/Ma ...

  6. unity3d 资源打包加密 整理

    资源打包脚本,放到Assets\Editor 文件夹下 using UnityEngine; using System.Collections; using UnityEditor; using Sy ...

  7. Unity3D入门基本概念整理

    1. (1)在场景中添加资源 只需单击工程视图 (Project View) 中的网格(Mesh)并拖动至层级视图 (Hierarchy) 或场景视图 (Scene View),便可将其添加至场景 ( ...

  8. [转]Unity3d之MonoBehaviour的可重写函数整理

    最近在学习Unity3d的知识.虽然有很多资料都有记录了,可是我为了以后自己复习的时候方便就记录下来吧!下面的这些函数在Unity3d程序开发中具有很重要的作用. Update 当MonoBehavi ...

  9. Unity3d之MonoBehaviour的可重写函数整理

    最近在学习Unity3d的知识.虽然有很多资料都有记录了,可是我为了以后自己复习的时候方便就记录下来吧!下面的这些函数在Unity3d程序开发中具有很重要的作用. Update 当MonoBehavi ...

随机推荐

  1. achieve aop through xml

    The main way to achive AOP is deploying a xml file. Now a xml file is presented to be a explanation ...

  2. expdp时遇到ORA-31693&ORA-02354&ORA-01466

    expdp时遇到ORA-31693&ORA-02354&ORA-01466 对一个schema运行expdp导出,expdp命令: nohup expdp HQ_X1/HQ_X1 DU ...

  3. INSTALL_FAILED_MEDIA_UNAVAILABLE错误处理

    问题描写叙述: 在android手机上安装apk的时候,报错例如以下: Installation error: INSTALL_FAILED_MEDIA_UNAVAILABLE Please chec ...

  4. Ajax改动购物车

    1.购物车类的设计 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2hpeWVxaWFuZ2xkaA==/font/5a6L5L2T/fontsize/4 ...

  5. MBR格式无法识别2T以上的硬盘的问题

    早上有人打电话说四块2T的sata 硬盘做了raid 5之后安装window server 2012的时候,无法创建分区,安装完系统后无法给剩余的硬盘创建分区,刚开始的时候我还以为是别人分区的数量问题 ...

  6. zoj3209(DLX)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=16234 题意:给p张小纸片, 问能不能选出尽量少的一部分或全部数量 ...

  7. java中HashMap在多线程环境下引起CPU100%的问题解决(转)

    最近项目中出现了Tomcat占用CPU100%的情况,原以为是代码中出现死循环,后台使用jstack做了dump,发现是系统中不合理使用HashMap导致出现了死循环(注意不是死锁). 产生这个死循环 ...

  8. 教你怎么去一个APP的JSON数据,你懂的

    今天闲着没事.谁让我今天是光棍节呢,算给大家一个福利.没事逛着应用市场.想找个应用高仿下,突然发现一个应用竟然跟我一个名字尼玛,尼玛应用界面做的非常easy.我认为应该不难. 惯性操作想去破解APK. ...

  9. IOS开发应用

    IOS开发应用 我的第一个IOS开发应用 1. 需求描述 2. 开发环境介绍 3. 创建一个工程 4. 工程配置介绍 5. 目录结构介绍 6. 界面设置 7. 关联输入输出 8. 关联事件代码 9.  ...

  10. C#获取设备的IP和Mac类

    /// <summary> /// 此类用于获得设备的Ip和Mac /// </summary> public class Mac { [DllImport("Iph ...