Answers for "how to execute a code only once in update function in unity (cursed method)"

C#
0

how to execute a code only once in update function in unity (cursed method)

sealed class CodeState {
	public string stateName;
    public CodeState(string stateName) {
    	this.stateName = stateName;
    }
}
public static class VarsNStuff {
	public static List<CodeState> states = new List<CodeState>() {new CodeState("Finished"),
    	new CodeState("Incomplete");
    }
}
private class Test : MonoBehaviour {
	private CodeState state = VarsNStuff.states[1];
    
    public override void Update() {
    	if (this.state != VarsNStuff.states[0]{ 
        	//Do code.
            foreach (dynamic state in VarsNStuff.states) {
            	if (this.state != state) {
                	this.state = state;
                    break;
                } }
        }
    }
}
Posted by: Guest on September-10-2021

Code answers related to "how to execute a code only once in update function in unity (cursed method)"

C# Answers by Framework

Browse Popular Code Answers by Language