ME FIRST GAMES
Menu

games for me and you

Unity Game Loop

6/4/2020

0 Comments

 
Picture
Understanding the flow of a MonoBehavior's life is important to writing great code.
📌 Awake: Init method called during Instantiation. This is a great place to initialize yourself and to cache references to components. This won't be called until the GameObject and Component become active for the first time.
​
📌 OnEnable: Init method called every-time the GameObject and Script is enabled from an off state. Subscribe to events or reset yourself here; use OnDisable as a corresponding cleanup.
📌 Start: Init method called after Awake is called on all enabled GameObjects. This is a great place init and interact with other components since Awake has already been called them.
📌 FixedUpdate: Called for each fixed-step in the physics loop. This may be called zero, once, or twice per frame update depending on the Fixed Timestep value in your project settings.
📌 Update: Called once per frame. This is a great place to constantly check something or poll input. The delta time between Update calls can fluctuate greatly depending on your framerate.
📌 LateUpdate: Called after all Update calls and right before the rendering lifecycle. This is a good place for camera controls since you know the player's position is already updated.
📌 OnDestroy: Called when the GameObject or Component is being destroyed and a great place to clean up non-scoped subscriptions. The normal Destroy call does not fire this immediately.
📌 Script Execution Order: Set the call order on scripts in your project settings. Instead of relying on Awake and Start, You can set the order of Player script to always be called before Camera script. This means, in the Camera Awake method, you know that Awake on Player was already called. 

0 Comments



Leave a Reply.

    Picture
    Me First Games is an independent game studio dedicated to creating unique and bizarre video games.
    GAMES HERE

    Red Matter

    Star Impact is an upcoming adventure platformer coming to PC, Mac, and Linux.

    Archives

    April 2021
    February 2021
    December 2020
    November 2020
    October 2020
    September 2020
    August 2020
    July 2020
    June 2020
    May 2020
    April 2019
    March 2019
    December 2018
    April 2018

    Categories

    All

    RSS Feed

Copyright (c) 2020 Me First LLC
  • STU the First AI
  • Blog
  • Contact
  • Unity Tools
    • Hierarchy Comments
  • STU the First AI
  • Blog
  • Contact
  • Unity Tools
    • Hierarchy Comments