c#

[Unity] 오브젝트 실행 순서

바르마스 2023. 1. 18. 11:10
728x90
public class LifeCycle
{
    //최초실행
    void Awake()
    {
        Debug.WriteLine("플레이어 데이터가 준비되었습니다");
    }
    //게임 오브젝트가 활성화 되었을떄 / 켜고 끌때마다 실행
    void OnEnable()
    {
        Debug.WriteLine("플레이어 로그인");
    }
    void Start()
    {
        Debug.WriteLine("사냥 장비를 챙겼습니다");
    }

    //물리연산 업데이트 / 1초에 50번정도
    void Fixedupdate()
    {
        Debug.WriteLine("이동");
    }
    //게임로직 업데이트 / 환경에따라 실행주기가 떨어짐
    void Update()
    {
        Debug.WriteLine("몬스터사냥");
    }


    //모든 업데이트 끝난후 / 카메라나 후처리
    void LateUpdate()
    {
        Debug.WriteLine("경험치 획득");
    }

    //게임 오브젝트가 비활성화 될때
    void OnDisable()
    {
        Debug.WriteLine("플레이어 로그아웃");
    }

    //오브젝트가 삭제될때 / 뭔갈 남길때
    void OnDestroy()
    {
        Debug.WriteLine("플레이어 데이터를 해체하였습니다");
    }
}
728x90