Unity/C# note

유니티 script로 Component 불러오기 RequireComponent 노트

오발탄LAB 2020. 8. 27. 23:47
반응형
[RequireComponent(typeof(AudioSource))]
public class ExampleScript : MonoBehaviour
{...}

해당 스크립트를 가지고 있는 오브젝트는 자동으로 AudioSource 컴포넌트가 생긴다.

 

[RequireComponent(typeof(AudioSource), RequireComponent(typeof(MeshRenderer))]
public class ExampleScript : MonoBehaviour
{...}

여러개 동시에 가능

반응형