Hi. So I’m making a game-speed clock for a strategy game (think like Xcom or Empire At War) with 4 buttons on it, and I’m using the new Unity 4.6 UI system with 4 buttons. Each one adjusts the timescale of the game to 0, 1, 10, and 100. See below:
[36007-x4+buttons.png|36007]
Clicking the buttons works fine, but the EventSystem (I think, but I don’t adequately understand it) seems to do what it likes with the spacebar; namely, it will ‘click’ the last button that I mouse-clicked on.
I want to use the spacebar to always alternate between hitting the Pause button and the X1 button, but I can’t. To get around this for now I’ve set the ‘left ctrl’ (“Dodge” in my input controls, see script below) button to activate these buttons, but I really want to just stop the spacebar doing its own thing so I can use it myself.
Any ideas? Here’s the script I’m using but I want to get rid of “Dodge” and use “Jump”(default spacebar button).
//FOR SPACEBAR PAUSING OR X1 SPEED
if(Input.GetButtonDown("Dodge"))
{
paused = !paused;
if(paused)
AdjustTimeScale(0);
else if(!paused)
AdjustTimeScale(1);
}
Note that hitting “Dodge” button calls a function ‘void AdjustTimeScale(float timeScale)’. Clicking the UI buttons calls the same function with their respective timeScale floats. Hitting “Dodge” does NOT activate a button click directly, though I’ve no objection to doing that if the solution requires it. I’m just not sure how to make the key translate to a button click so I made the key go straight to the function.
Thanks
Kevin
PS I removed all the “jump” (spacebar) inputs from the Input controls but this had no effect.