Properties in Unity3d (Attributes) collation

Source: Internet
Author: User

The attributes property belongs to the runtimeclass of u3d, so it is necessary to add the following namespaces. There's nothing else to pay attention to. This article passes through all the running properties.
Want to see more detailed points here
using UnityEngine;
using System.Collections;

1. [Addcomponentmenu] Add component Menu

This function is easy to use, the original script (build) will be in the "Component/script" menu, before the class to declare this, it can appear in the "Componet" menu anywhere. The description refers to restarting u3d to display, but the test appears to be directly visible.

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

2. [ContextMenu] Context Menu

This translation I feel very unnatural, in fact, the context is what things ... This function is to add a trigger event in the Inspector script, which is the drop-down menu that removes the script Reset Script button, which is difficult to tell, so I cut a picture.

public class Attributes : MonoBehaviour {
[ContextMenu("Hello World!")]
void HelloWorld()
{
Debug.Log("Hello World!");
}
}
Unity3d中的属性(Attributes)整理

3. Executeineditmode running in editor mode

As a name, run in the editor. However, there are three ways to call functions.

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 hidden in the Inspector panel

public class HideInspectorTest : MonoBehaviour
{
[HideInInspector]
public Transform m_Target;
void Start()
{
m_Target = GameObject.Find("test").transform;
}
}

5. Requirecomponent must have a corresponding formation

There must be another corresponding build before joining a build, and if not, it is created automatically. This is very necessary in the project, especially when the project staff is more (more than three or four).
[RequireComponent (typeof (Rigidbody))]
public class RequireComponentTest : MonoBehaviour {
void FixedUpdate() {
rigidbody.AddForce(Vector3.up);
}
}

6. NonSerialized not be serialized

The variable is not serialized and is not displayed in the Inspector panel.
public class Test {
[System.NonSerialized]
public int i_Helloword = 5;
}

7. Serializable Serializable

This property can be used to display the variable properties of a subclass (inheriting class) in the inspector or to serialize it. (JS words do not need this attribute at all.) )
//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 serialization domain (forced serialization)

It is well written here that you can serialize the private variables, serialize the built-in variables of the u3d, and so on.
Http://game.ceeger.com/Script/Attributes/SerializeField.html

9. The attribute property below is estimated to be useless, and I haven't used it much.
  1. Imageeffectopaque opaque image effect is preferred
    *any Image Effect With this attribute would be a 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 is used to reduce the amount of visual artifacts in a scene with post processing.*
    It's useless, but it should be used infrequently, and optimized for accelerated rendering.

  2. Imageeffecttransformstoldr
    And it doesn't work, LDR should be some kind of loading mode. High dynamic illumination rendering (High-dynamic Range, referred to as HDR).
    *when using HDR rendering it can sometime be desirable to switch to LDR rendering during imageeffect rendering.
    Using this Attribute in an image effect would cause the destination buffer to is an LDR buffer, and switch the rest of the Image Effect pipeline into LDR mode. It is the responsibility of the Image Effect, this Attribute is associated to ensure the output was in the LDR ran Ge.*

  3. Notconvertedattribute do not convert properties
    I think this should be no one to use ... When packaging resources, not converting members or types to the appropriate platform, you don't really understand what this is all about.
    Instructs the build pipeline not to convert a type or member to the target platform.

  4. Notflashvalidatedattribute conversion to flash platform is not allowed
    Is it another thing that nobody uses?
    Instructs the build pipeline not-to-try and validate a type or member for the Flash platform.

  5. Notrenamedattribute property Renaming is not allowed
    ......

  6. PropertyAttribute Property Property? I don't understand.
    I don't know what to do with it.

  7. PRC
    This seems to be related to the network, u3d of the network slag, regardless of.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Properties in Unity3d (Attributes) collation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.