My first Toggles post was getting a little messy so wanted to repost with the code. My first two problems have largely been corrected, however I’m still having two problems:
-
I’m still having trouble setting it up so clicking on movement subtype changes the style of the move icon itself. I want to show which movement type is active by changing the appearance of the move button.
-
It’s still possible to de-select a toggle that’s been selected by clicking itself. I want to make it so that a toggle can only be deselected by clicking a different toggle.
Here is the relevant parts of my code so far:
function OnGUI() { GUI.skin = VacantSkin; ... //Toggles Move toggleMove = GUI.Toggle (Rect (140,49,18,57), toggleMove, "", "WalkIcon"); if (toggleMove && (action_state != "move")) { toggleMove = setMeOnly(); action_state = "move"; } //Toggles Walk toggleWalk = GUI.Toggle (Rect (145,18,11,28), toggleWalk, "", "WalkButton"); if (toggleWalk && (move_state != "walk")) { toggleWalk = setMeOnly(); move_state = "walk"; toggleMove = true; } //Toggles Run toggleRun = GUI.Toggle (Rect (181,38,19,28), toggleRun, "", "RunButton"); if (toggleRun && (move_state != "run")) { toggleRun = setMeOnly(); move_state = "run"; toggleMove = true; } //Toggles Stealth toggleStealth = GUI.Toggle (Rect (101,38,19,28), toggleStealth, "", "StealthButton"); if (toggleStealth && (move_state != "stealth")) { toggleStealth = setMeOnly(); move_state = "stealth"; toggleMove = true; } //Toggles Interact toggleInteract = GUI.Toggle (Rect (217,111,46,60), toggleInteract, "", "Interact"); if (toggleInteract && (action_state != "interact")) { toggleInteract = setMeOnly(); action_state = "interact"; } }