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";
}
}
1) I've tried several different ways of setting something like that up, I just can't seem to figure out what the code for that would look like. 2) I actually was able to fix that part after some searching.
– AmbaryernoWere you talking about something like this: <pre>var = changeStyle</code> Then, when it comes time to change the style, add this to the relevant If statement on the button being pressed: <pre>changeStyle (button to change) = (new style to use);</code> I've tried a couple ways to call up a new style on a toggle or button-press, but it either doesn't do anything at all, or I get a compiler error before I can try running the game.
– Ambaryerno