How do I avoid allocating resources to unused variables?
I'm trying to optimize some scripts of mine, I have scripts that have functionality I can toggle on and off depending on use case.
One object may not need the light functionality of my scripts for example.
I know one solution is to make separate components, but that really gets noisy in some cases.
The particle system for example has modules the user can disable, I'd like to assume that variables of such disabled modules aren't allocated at all.
// light
public bool useLight = false;
public Light light;
public Color color;
public ParticleSystem particleSystem;
private float lightStrength;
So, If I set useLight to false, is there any way to not allocate resources to all of its supporting variables?
I hope this question was clear.
Your answer
Follow this Question
Related Questions
Unable to edit fields from custom inspector 1 Answer
Referencing variables from another script each time it is needed. 0 Answers
Alternative to using .toString ? 0 Answers
why is this code not working 0 Answers
Static Class Strings not truly null? 1 Answer