Develop/Unity

Unity 객체 생성 , 메서드 호출 등 자주쓰이는 기능

dlsdnd345 2016. 2. 13. 20:07

Unity 객체 생성 , 메서드 호출 등 자주쓰이는 기능



​​1.메서드 호출 및 송신


GameObject.Find("1").SendMessage("2","3");


  1. 해당 클래스가 들어 있는 GameObject 이름

  2. 해당 클래스의 호출 하고 싶은 메서드 이름

  3. 보내는 데이터가 없을시 - SendMessageOptions.DontRequireReceiver

   보내는 데이터가 있을시 - "보낼데이터를 넣어 준다."

    


2. 객체 생성

 

private SpawnMultipleObjects spawnMultipleObjects;

spawnMultipleObjects = GameObject.Find("1").GetComponent<SpawnMultipleObjects>();

​1. 생성할 객체가 들어 있는 GameObject 를 입력



3. 화면 호출


Application.LoadLevel("Scene 이름");




4. GameObject 속성 접근


monster.GetComponent<Rigidbody2D> ().gravityScale = 5;


클래스가 들어 있는 GameObject 의 속성을 접근 할때 사용

<"안에 사용하고 싶은 속성">