Skip to content

Instantly share code, notes, and snippets.

@charlieamat
Created September 14, 2021 15:57
Show Gist options
  • Save charlieamat/090a7d4473c8c1c6724407046a89c244 to your computer and use it in GitHub Desktop.
Save charlieamat/090a7d4473c8c1c6724407046a89c244 to your computer and use it in GitHub Desktop.
[ta-edu-course-survival-game] Chapter 2—Performance 101 (3)
  1. Click anywhere in the CPU Usage graph
    • We can see that our Update method is taking up a much larger portion of the frame
  2. Change the bottom section of the profiler from timeline to hierarchy view
    • The timeline view is a good visualization, but the hierarchy view provides more actionable information
  3. Order the hierarchy view by “Time ms” and expand “PlayerLoop” all the way down to the script logic
    • By ordering the view by “Time ms” we can narrow down what is taking the CPU so long to execute
    • FindObjectsOfType is taking up some time, so let’s fix that
  4. Switch to Visual Studio
  5. Convert interactables to a private member variable
  6. Initialize interactables in the Start method
    • It’s best to initialize this at the start of the scene instead of every frame
    • This works because we know our scene won’t change

We decreased how long it takes for our script to run each frame but we aren’t done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment