유니티 의존 컴포넌트를 자동추가


using UnityEngine;

// PlayerScript requires the GameObject to have a Rigidbody component
[RequireComponent (typeof (Rigidbody))]
public class PlayerScript : MonoBehaviour {
	Rigidbody rb;
	
	void Start() {
		rb = GetComponent();
	}
	void FixedUpdate()  {
		rb.AddForce(Vector3.up);
	}
}
출처:
https://docs.unity3d.com/ScriptReference/RequireComponent.html

댓글

이 블로그의 인기 게시물

유니티 오브젝트 서서히 사라지게

WebView에서 YOUTUBE 동영상 플레이 방법