반응형
AddComponentMenu : 유니티 메뉴 추가.
// C# example: [AddComponentMenu("Transform/Follow Transform")] public class FollowTransform : MonoBehaviour { }
ContextMenu : 우클릭 메뉴 추가.
// C# example: public class ContextTesting : MonoBehaviour { /// Add a context menu named "Do Something" in the inspector /// of the attached script. [ContextMenu ("Do Something")] void DoSomething () { Debug.Log ("Perform operation"); } }
ExecuteInEditMode : 에디트 모드에서 스크립트 실행.
using UnityEngine; using System.Collections; [ExecuteInEditMode] public class example : MonoBehaviour { public Transform target; void Update() { if (target) transform.LookAt(target); } }
HideInInspector : 인스펙터에서 속성 감추기, 이전 세팅값은 유지.
using UnityEngine; using System.Collections; public class example : MonoBehaviour { [HideInInspector] public int p = 5; }
NonSerialized : 인스펙터에서 속성 감추기, 이전 세팅값은 무시.
// C# Example class Test { // p will not be shown in the inspector or serialized [System.NonSerialized] public int p = 5; }
RPC : 원격지 호출 함수로 지정, 보내는 쪽과 받는 쪽 모두 다 존재해야 함.
using UnityEngine; using System.Collections; public class example : MonoBehaviour { public Transform cubePrefab; void OnGUI() { if (GUILayout.Button("SpawnBox")) { NetworkViewID viewID = Network.AllocateViewID(); networkView.RPC("SpawnBox", RPCMode.AllBuffered, viewID, transform.position); } } [RPC] void SpawnBox(NetworkViewID viewID, Vector3 location) { Transform clone; clone = Instantiate(cubePrefab, location, Quaternion.identity) as Transform as Transform; NetworkView nView; nView = clone.GetComponent<NetworkView>(); nView.viewID = viewID; } }
RequireComponent : 컴포넌트 자동 추가.
[RequireComponent (typeof (Rigidbody))] public class PlayerScript : MonoBehaviour { void FixedUpdate() { rigidbody.AddForce(Vector3.up); } }
Serializable : 인스펙터에 인스턴스의 하위 속성 노출.
// C# Example [System.Serializable] class Test { public int p = 5; public Color c = Color.white; } class Sample : MonoBehaviour { public Test serializableObj; // 인스펙터에 p, c가 노출된다. }
SerializeField : 인스펙터에 비공개 멤버 노출.
//C# example using UnityEngine; public class SomePerson : MonoBehaviour { //This field gets serialized because it is public. public string name = "John"; //This field does not get serialized because it is private. private int age = 40; //This field gets serialized even though it is private //because it has the SerializeField attribute applied. [SerializeField] private bool hasHealthPotion = true; void Update () { } }
반응형
'개발 Tip > Unity3D' 카테고리의 다른 글
Unity3D 어셋(Assets)들을 관리해주는 툴이다. (1) | 2013.11.12 |
---|---|
[뉴스] 유니티, 유나이트 벤쿠버 2013에서 ‘2D엔진’ 공개 (0) | 2013.10.16 |
[펌] Unity3D 최적화 (0) | 2013.10.16 |
[펌] [NGUI] 스코어의 남은 자릿수를 0으로 채우기 (0) | 2013.10.08 |
[펌] Unity3D Particle System (Legacy) 간략 설명 (0) | 2013.10.08 |