2014-11-21 2 views
1

Start() 메서드와 Update() 메서드 모두에서 메서드가 호출되지 않는데 OnDrawGizmos() 메서드가 실행되는 이유를 이해할 수 없지만 Unity 프로젝트를 실행할 때 실행됩니다. 그것이 documentation에 따라, MonoBehaviour를 구현하는 클래스에 유니티라고 때문에Unity에서 코드에서 호출하지 않을 때 내 메서드가 호출되는 이유는 무엇입니까?

using UnityEngine; 
using System.Collections; 

public class PlayerController : MonoBehaviour 
{ 
    public Transform grounder; 


    // Use this for initialization 
    void Start() { 

    } 

    // Update is called once per frame 
    void Update() { 

    } 

    void OnDrawGizmos(){ 
     Gizmos.color = Color.white; 
     Gizmos.DrawSphere (grounder.position, 1); 
    } 
} 

답변

2

.

+0

알겠습니다. 형제 님 감사합니다! –

3

이름에서 알 수 있듯이 OnDrawGizmozs은 유니티 엔진에 의해 호출됩니다. MonoBehaviour를 구현하는 클래스에서 호출되는 메시지 함수입니다. 문서에서 Excert : 당신은 또한 pickable 항상 그려 간단한 장치를 그리려는 경우

이 OnDrawGizmos을 구현

설명.

http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnDrawGizmos.html

이것은 당신이 함수를 직접 호출 할 필요는 없습니다 것을 의미합니다.

+0

알 겠어. 형제 님 감사합니다! –

관련 문제