I need change a boolean variable, and I need put the OnMouseDown and onMouseUp events for this GUI.Button for move my camera, please can someone help me with that !?
Thanx for your time, thanks for your help, thanks at all :)
I need change a boolean variable, and I need put the OnMouseDown and onMouseUp events for this GUI.Button for move my camera, please can someone help me with that !?
Thanx for your time, thanks for your help, thanks at all :)
Edit: Found out that this was the basic behavior of the buttons :)
Maby you can do something like this
bool buttonDown = false;
if(GUI.Button())
{
OnMouseDown();
buttonDown = true;
}
else if(buttonDown)
{
buttonDown = false;
OnMouseUp();
}
sorry bother you, doesn't work it because, when I press the button, the camera doesn't move, and I release de button, the camera move just do it one time, and I need the camera moves while the button been pressed. :(
– anon54788915Sorry I get it, the answer is change GUI.Button for GUI.ButtonRepeat, hahaha, it was driving me crazy, but finally I get it thanks for at all
– anon54788915
Can you give more details, please? I don't understand what exactly you want to do..
– Jake-LOk, thanks, I have a boolean variable named move, and I need to move the camera when my GUI.Button have been pressed, because it change the move variable to true, when my GUI.Button stop pressed, the boolean variable should changed to false, for this, I create this script, and my _target Transform variable is the camera, because I attach it, this is my code for now
– anon54788915using UnityEngine; using System.Collections; [AddComponentMenu("Interfase/Controller")] public class VisualAndTouchController : MonoBehaviour { public Transform mainCamera; public int velocity = 5; public Texture2D buttonUP; private bool moveUP = false; void Update(){ if(moveUP) mainCamera.Translate(Vector3.forward * (Time.deltaTime*velocity)); } void OnGUI() { GUI.backgroundColor = Color.clear; if(GUI.Button(new Rect(Screen.width/2,Screen.height-100,48,48),buttonUP)){ moveUP = !moveUP; } } }
– anon54788915