public static void UpdateValues()
 {
     if (OnValueChanged != null)
     {
         OnValueChanged.Invoke();
     }
 }
        void CheckForEvents()
        {
            fixedRotationValue = FixRotation(transform.localEulerAngles[(int)rotationAxis]);
            amountRotated      = Mathf.Lerp(0, 1, (fixedRotationValue - minAngle) / (maxAngle - minAngle));

            if (amountRotated == 0 && !clampAngleReached)
            {
                onMinAngleReached.Invoke();
                clampAngleReached = true;
            }
            else if (amountRotated == 1 && !clampAngleReached)
            {
                onMaxAngleReached.Invoke();
                clampAngleReached = true;
            }
            else if (amountRotated != 0 && amountRotated != 1)
            {
                clampAngleReached = false;
            }

            if (amountRotated != prevAmountRotated)
            {
                onValueChanged.Invoke(amountRotated);
            }

            prevAmountRotated = amountRotated;
        }
Example #3
0
        private void onValueChanged()
        {
            var args = new SliderValueEventArgs(_value);

            OnValueChanging.Invoke(args);
            OnValueChanged.Invoke(args);
        }
        void CheckForEvents()
        {
            float amountSlided = clamper.GetAmountMoved();

            if (amountSlided == 0 && !clampPointReached)
            {
                onPointAReached.Invoke();
                clampPointReached = true;
            }
            else if (amountSlided == 1 && !clampPointReached)
            {
                onPointBReached.Invoke();
                clampPointReached = true;
            }
            else if (amountSlided != 0 && amountSlided != 1)
            {
                clampPointReached = false;
            }

            if (amountSlided != prevAmountMoved)
            {
                onValueChanged.Invoke(amountSlided);
            }

            prevAmountMoved = amountSlided;
        }
Example #5
0
        private void FormatText()
        {
            string[] Parts = TheTimeBox.Text.Trim().Split(':');

            int Hours = 0;

            if (!int.TryParse(Parts[0], out Hours))
            {
                Hours = 0;
            }

            if (Hours >= 23)
            {
                Hours = 23;
            }

            int Minutes = 0;

            if (Parts.Length < 2 || !int.TryParse(Parts[1], out Minutes))
            {
                Minutes = 0;
            }
            if (Minutes >= 59)
            {
                Minutes = 59;
            }

            SetText(Hours.ToString("D2"), Minutes.ToString("D2"));
            if (OnValueChanged != null)
            {
                OnValueChanged.Invoke(null, new EventArgs());
            }
        }
 void InvokeValueChanged()
 {
     if (onValueChanged != null)
     {
         onValueChanged.Invoke(this, Value);
     }
 }
Example #7
0
 /// <summary>
 /// Accessor to call change event handlers.
 /// </summary>
 ///
 protected void InvokeOnValueChanged()
 {
     if (OnValueChanged != null)
     {
         OnValueChanged.Invoke(this);
     }
 }
Example #8
0
        /// <summary>
        /// Handles lerp logic and destruction of the component on finish if desired.
        /// </summary>
        private void UpdateLogic()
        {
            if (isRunning && !lerpTimerService.Finished)
            {
                //This MUST be done inside this condition because otherwise time will
                //tick forward during any Update and not only during lerp
                //Also, if you don't do this first then you encounter another fault
                //where values will never reach their true final lerp target.
                lerpTimerService.StepTimeForward();

                //Tick the lerp forward and broadcast changed value.
                //For now assume change during lerping.
                TLerpType lerpValue = ComputeNextLerpValue();

                if (OnValueChanged != null)
                {
                    OnValueChanged.Invoke(lerpValue);
                }

                //Could be finished here, best place to check it
                if (lerpTimerService.Finished)
                {
                    if (OnLerpEnded != null)
                    {
                        OnLerpEnded.Invoke();
                    }
                }
            }

            if (lerpTimerService.Finished && _DestroyOnFinished)
            {
                Destroy(this);
            }
        }
Example #9
0
 private void M_valueInput_ValueChanged(object sender, EventArgs e)
 {
     InsertValue((ushort)((NumericUpDown)sender).Value);
     if (ValueChanged != null)
     {
         ValueChanged.Invoke(this);
     }
 }
Example #10
0
 private void OnMouseButtonPressed(object?sender, MouseButtonEventArgs e)
 {
     _clicked = UpdateHandle(new Vector2f(e.X, e.Y));
     if (_clicked && OnValueChanged != null)
     {
         OnValueChanged.Invoke(this);
     }
 }
 /// <summary>
 /// Sets the toggled state.
 /// </summary>
 /// <param name="value"></param>
 public override void SetToggled(bool value)
 {
     if (GetToggled())
     {
         return;
     }
     base.SetToggled(value);
     _OnValueChanged.Invoke(Id);
 }
Example #12
0
        public virtual void Rebuild(CanvasUpdate executing)
        {
#if UNITY_EDITOR
            if (executing == CanvasUpdate.Prelayout)
            {
                OnValueChanged.Invoke(LowValue, HighValue);
            }
#endif
        }
Example #13
0
 public void UpdateBind()
 {
     if (!CheckNull()) return;
     var oldValue = (bool)fieldInfo.GetValue(Target);
     var activeIndex = Array.FindIndex(toggles, t => t.isOn);
     fieldInfo.SetValue(Target, activeIndex == 0);
     if (oldValue != (activeIndex == 0))
         OnValueChanged.Invoke(activeIndex == 0);
 }
 public float Add(float _amount)
 {
     currentHealth += _amount;
     if (OnValueChanged != null)
     {
         OnValueChanged.Invoke(currentHealth);
     }
     return(currentHealth);
 }
        /// <summary>
        ///
        /// </summary>
        protected virtual void DispatchValueChangeEvent()
        {
            if (mSetter != null)
            {
                mSetter.Invoke(mValue);

                OnValueChanged.Invoke(mValue);
            }
        }
Example #16
0
    /// <summary>
    /// Sets the event listener which will be called when the value of the dropdown
    /// menu is changed. The listener will be passed the value of the drop down.
    /// </summary>
    /// <param name="vHandler">The call function with the newly changed argument.</param>
    private void OnValueChange(float val)
    {
        UpdateEcho(val);

        if (onValueChange != null)
        {
            onValueChange.Invoke(id, val);
        }
    }
Example #17
0
 public float Remove(float _amount)
 {
     currentAmmo -= _amount;
     if (OnValueChanged != null)
     {
         OnValueChanged.Invoke(currentAmmo);
     }
     return(currentAmmo);
 }
Example #18
0
 // Update is called once per frame
 void Update()
 {
     if (lastValue != Value)
     {
         onValueChanged.Invoke(Value);
     }
     lastValue      = Value;
     scrollbar.size = Value;
 }
Example #19
0
        private void FormatText()
        {
            string[] Parts = TheTimeBox.Text.Trim().Split(":".ToCharArray());

            int Hours = 0;

            if (!int.TryParse(Parts[0], out Hours))
            {
                Hours = 0;
            }
            if (Hours >= 24)
            {
                Hours = 0;
            }

            int Minutes = 0;

            if (!int.TryParse(Parts[1], out Minutes))
            {
                Minutes = 0;
            }
            if (Minutes >= 60)
            {
                Minutes = 0;
            }

            string[] SecondParts = Parts[2].Split(".".ToCharArray());

            int Seconds = 0;

            if (!int.TryParse(SecondParts[0], out Seconds))
            {
                Seconds = 0;
            }
            if (Seconds >= 60)
            {
                Seconds = 0;
            }

            int Milliseconds = 0;

            if (!int.TryParse(SecondParts[1], out Milliseconds))
            {
                Milliseconds = 0;
            }
            if (Milliseconds >= 1000)
            {
                Milliseconds = 0;
            }

            SetText(Hours.ToString("D2"), Minutes.ToString("D2"), Seconds.ToString("D2"), Milliseconds.ToString("D3"));
            if (OnValueChanged != null)
            {
                OnValueChanged.Invoke(null, new EventArgs());
            }
        }
        public override void SetValue(string value)
        {
            if (GetValue() == value)
            {
                return;
            }

            OnValueChanged.Invoke(value);
            MyPlayerPrefs.SaveString(key, value);
        }
        public override void SetValue(float value)
        {
            if (GetValue() == value)
            {
                return;
            }

            OnValueChanged.Invoke(value);
            MyPlayerPrefs.SaveFloat(key, value);
        }
        /// <summary>
        ///
        /// </summary>
        protected virtual void DispatchValueChangeEvent()
        {
            if (mSetter != null)
            {
                mSetter.Invoke(mValue);
#if UNITY_5_6_OR_NEWER
                OnValueChanged.Invoke(mValue);
#endif
            }
        }
 private void floatValueControl_ValueChanged(object sender, EventArgs e)
 {
     //Console.WriteLine(floatValueControl.Value);
     if (OnValueChanged != null)
     {
         byte[] data = BitConverter.GetBytes((float)floatValueControl.Value);
         Array.Reverse(data);
         OnValueChanged.Invoke(this, data);
     }
 }
Example #24
0
 public void Draw()
 {
     _currentValue = GUI.HorizontalSlider(_rect, _currentValue, _minValue, _maxValue);
     if (_currentValue != _previousValue)
     {
         if (OnValueChanged != null)
         {
             OnValueChanged.Invoke(_currentValue);
         }
     }
 }
Example #25
0
        public void StartLerp()
        {
            //It's probably a good idea to set the current value to the start value
            //When a start is requested since time will tick forward first call
            if (OnValueChanged != null)
            {
                OnValueChanged.Invoke(StartingValue);
            }

            isRunning = true;
        }
Example #26
0
        public override void SetValue(long value)
        {
            if (GetValue() == value)
            {
                return;
            }

            this.value = value;
            OnValueChanged.Invoke(value);
            MyPlayerPrefs.SaveString(key, value.ToString());
        }
Example #27
0
 public void UpdateSelection()
 {
     prevButton.interactable = selectedOption > 0;
     nextButton.interactable = selectedOption < options.Length - 1;
     //optionLabel.text = options[selectedOption];
     optionLabel.GetComponent <Localize>().Term = options[selectedOption];
     if (OnUpdate != null)
     {
         OnUpdate.Invoke(selectedOption);
     }
 }
Example #28
0
        public override void SetValue(int value)
        {
            if (GetValue() == value)
            {
                return;
            }

            this.value = value;
            OnValueChanged.Invoke(value);
            MyPlayerPrefs.SaveInt(key, value);
        }
Example #29
0
 private void OnMouseMoved(object sender, MouseMoveEventArgs e)
 {
     if (!_clicked)
     {
         return;
     }
     UpdateHandle(new Vector2f(e.X, _position.Y));
     if (OnValueChanged != null)
     {
         OnValueChanged.Invoke(this);
     }
 }
Example #30
0
    public void OnDrag(WandController controller)
    {
        float   offset     = parentAxis.CalculateLinearMapping(controller.transform);
        Vector3 axisOffset = new Vector3(transform.localPosition.x, 0, 0);

        transform.localPosition = Vector3.Lerp(new Vector3(transform.localPosition.x, -0.5f, 0),
                                               new Vector3(transform.localPosition.x, 0.5f, 0),
                                               offset);
        parentAxis.isDirty = true;

        onValueChanged.Invoke(transform.localPosition.y);
    }