#TODO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FadingInteractable : Interactable | |
{ | |
[SerializeField] private float duration = 3; | |
private Renderer _renderer; | |
public void Interact() | |
{ | |
StartCoroutine(FadeOut); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Interactable : MonoBehaviour | |
{ | |
private InteractionHandler[] _handlers; | |
public void Awake() | |
{ | |
_handlers = GetComponents<InteractionHandler>(); | |
} | |
public void Interact() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Interactions; | |
using NUnit.Framework; | |
using UnityEngine; | |
using UnityEngine.TestTools; | |
public class InteractionHandlerTests | |
{ | |
public class FadeOutTests | |
{ | |
[UnityTest] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Combatant : MonoBehaviour | |
{ | |
public float Health; | |
public void Damage(int damage) | |
{ | |
Health = Math.Max(0, Health - damage); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO |
- Click anywhere in the CPU Usage graph
- We can see that our Update method is taking up a much larger portion of the frame
- 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
- 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
- Switch to Visual Studio
- Convert interactables to a private member variable
- Initialize interactables in the Start method
- In the top navigation bar, click Window → Analysis → Profiler
- (optional) Dock the profiler to the editor
- Enable only the CPU Usage and Memory modules
- Each profiler module provides information about a certain aspect of your game’s performance
- Performance issues related to your code will appear in the CPU Usage and Memory modules
- Run the scene, wait a few seconds, and press the pause button
- The profiler window is split into two sections
- The top shows a set of time-based graphs
- The bottom gives information about the selected frame that’s contextual to the module that is currently in focus
- The profiler window is split into two sections
- Click on a frame in the CPU Usage graph
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FadingInteractable : Interactable | |
{ | |
[SerializeField] private float duration = 3; | |
private float _elapsed; | |
private Renderer _renderer; | |
private bool _isFading; | |
public void Interact() | |
{ |
NewerOlder