Unity performance questions
I'm making a menu manager and I'm not sure what should I do to make a transition from one menu to the other. What is better to used? performance wise? Here is the step in my mind.
Simple enable or disable menu. Change alpha 0 or 1. Move the menu outside of canvas. So what is better?
My second question is about static class.
Here is my sample code
if (dash)
{
Player.Instance.Speed = Player.Instance.DashSpeed;
Player.Instance.CurrentStamina -= 0.5f;
if (Player.Instance.CurrentStamina < 0)
Player.Instance.CurrentStamina = 0;
}
else
{
Player.Instance.Speed = speedCache;
Player.Instance.CurrentStamina += 1f;
if (Player.Instance.CurrentStamina >= Player.Instance.MaxStamina)
Player.Instance.CurrentStamina = Player.Instance.MaxStamina;
}
So, basically I constantly get;set; this variable from Player class, is it a bad?
Answer by LightSource · Dec 09, 2015 at 03:01 PM
Changing the alpha means the frame is still rendered, just invisible. Moving it means it could (maybe) be occluded and draws could be saved. It might be best just turn turn off the GameObject, but to be honest, none of these options seriously impacts performance, especially with a menu.
As long as you aren't dynamically serching for an object, getting or setting a primative type should be totally fine.
Your answer
Follow this Question
Related Questions
Freeze OnGUI() 1 Answer
Horrible Lag spike when Looking at an object that's showing GUI 1 Answer
GUI texture not showing up in unity 5? 1 Answer
How to change GUI label size 1 Answer