Ejemplo n.º 1
0
        protected override void OnClick(EventArgs e)
        {
//            Point p = PointToClient(Control.MousePosition);
            Point p = ((MouseEventArgs)e).Location;

            _ToggleState = (p.X < Width / 2) ? ToggleStates.Left : ToggleStates.Right;

            base.OnClick(e);

            Refresh();
        } //protected override void OnClick(EventArgs e)
Ejemplo n.º 2
0
        public void Apply(float value)
        {
            bool isDown = value > Threshold;

            if (_isEnabled != isDown)
            {
                _isEnabled = isDown;

                if (Toggles)
                {
                    if (isDown)
                    {
                        if (ToggleStates.Contains(_control.CurrentShiftState))
                        {
                            int index = ToggleStates.IndexOf(_control.CurrentShiftState);

                            if (ToggleStates.Count > index + 1)
                            {
                                _control.ChangeState(ToggleStates[index + 1]);
                            }
                            else
                            {
                                _control.ChangeState(ToggleStates[0]);
                            }
                        }
                        else
                        {
                            _control.ChangeState(ToggleStates[0]);
                        }
                    }
                }
                else if (isDown)
                {
                    if (TargetState != _control.CurrentShiftState)
                    {
                        _previousState = _control.CurrentShiftState;
                    }

                    _control.ChangeState(TargetState);
                }
                else
                {
                    _control.ChangeState(_previousState);
                }
            }
        }
Ejemplo n.º 3
0
 private void OnEnable()
 {
     skin                = (GUISkin)Resources.Load(EasyMotionConstants.pluginSkin);
     easyMotion          = (EasyMotion)serializedObject.targetObject;
     toggleStatesScripts = Resources.FindObjectsOfTypeAll <ToggleStates>();
     if (toggleStatesScripts.Length > 0)
     {
         toggleStates = toggleStatesScripts[0];
     }
     if (easyMotion.gameObject.activeInHierarchy)
     {
         InitialiseVisualAidPrefab();
         lookingForVisualAidPrefab = true;
         FindVisualAidPrefab();
         GetGroupHeaderStates();
         GetVisualAidStates();
         GetJitterEffectState();
         objectActivated = true;
     }
 }
    public void Trigger(bool val)
    {
        Debug.Log(" dt " + (Time.time - lastTimeChange > minTime));
        if (!histeresis || (Time.time - lastTimeChange > minTime))
        {
            lastTimeChange = Time.time;
            toggleState    = val ? ToggleStates.toggleOn : ToggleStates.toggleOff;
            if (toggleEvent != null)
            {
                toggleEvent.Invoke(val);
            }
            if (whenTrue != null && val)
            {
                whenTrue.Invoke();
            }
            if (whenFalse != null && val)
            {
                whenFalse.Invoke();
            }
        }
        else
        {
            if (!isWaiting)
            {
                if (mono == null)
                {
                    Debug.Log("no mono");
                    return;
                }

                mono.StartCoroutine(waitRoutine());
            }
            if (toggleState == ToggleStates.toggleOn)
            {
                toggleState = ToggleStates.toggleOnPendingOff;
                Debug.Log("state pending off " + Time.time);
            }
            else
            if (toggleState == ToggleStates.toggleOff)
            {
                toggleState = ToggleStates.toggleOffPendingOn;
                Debug.Log("state pending on " + Time.time);
            }
            else
            if (toggleState == ToggleStates.toggleOffPendingOn)
            {
                if (val == false)
                {
                    toggleState = ToggleStates.toggleOff;
                }
            }
            else
            if (toggleState == ToggleStates.toggleOnPendingOff)
            {
                if (val == true)
                {
                    toggleState = ToggleStates.toggleOn;
                }
            }
        }
    }