Created
February 24, 2017 16:36
-
-
Save herman-rogers/ee819557973c8dd111481844be534f83 to your computer and use it in GitHub Desktop.
Flux implementation in Unity
This file contains 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
Props stateTree = {name: "InitialState", value: 0}; | |
Props stateOneProps = { | |
name: "SceneOne" | |
value: 1 | |
} | |
Props stateTwoProps = { | |
name: "SceneTwo" | |
} | |
TreeUpdator(newProps) { | |
Props newTree = stateTree | |
// if state props are null keep old state; aka magiks | |
newTree.name = newProps.name; | |
newTree.value = newProps.value; | |
// essentially just assign a new tree each time, not modify it | |
stateTree = newTree | |
} | |
TreeUpdator(stateOneProps) | |
//stateTree.name should be "SceneOne", value should be 1 | |
TreeUpdator(stateTwoProps) | |
//stateTree.name should be "SceneTwo", value should be 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment