// Update is called once per frame public virtual void Update() { mJustPressed = false; mJustReleased = false; if(!mEnabled || mSharedTime == Time.time || (mSharedAnyPressed != this && mSharedAnyPressed != null)) return; Vector2 mousePos = InputHelp.mousePosition; if(InputHelp.GetMouseButtonDown(0)) { if(rec.Contains(mousePos)) { mMouseInit = mousePos; mMovement = Vector2.zero; mPressed = true; mJustPressed = true; OnButtonPressed(); mSharedTime = Time.time; mSharedAnyPressed = this; } } else if(mPressed) { if(InputHelp.GetMouseButton(0)) { if(!rec.Contains(mousePos) || InputHelp.fingerChange) { mPressed = false; OnButtonReleasedNotContained(); mSharedAnyPressed = null; } else if(disableOnMouseMove) { mMovement += mousePos - mMouseInit; if(mMovement.sqrMagnitude > MAXDISABLEBUTTONS) { mMovement.x = 300; mPressed = false; OnButtonReleasedNotContained(); mSharedAnyPressed = null; } } mMouseInit = mousePos; } else if(InputHelp.GetMouseButtonUp(0)) { if(mKeepState) { mChecked = !mChecked; } mJustReleased = true; mSharedAnyPressed = null; mPressed = false; OnButtonReleased(); } } }
public virtual void Reset() { /*if(mPressed) OnButtonReleased();*/ mEnabled = true; mPressed = false; mChecked = false; mJustPressed = false; mJustReleased = false; mSharedAnyPressed = null; }