Beispiel #1
0
        protected void SetValue(long val, PropertyEventOptions opts = PropertyEventOptions.SendOnChange)
        {
                        #if BT_DEBUG_UNSTRIP
            if (m_debug)
            {
                Debug.Log("[" + Time.frameCount + "][" + this.Path() + "] " + GetType() + "::set_value to " + val);
            }
                        #endif

            if (opts != PropertyEventOptions.Force && val == GetValue())
            {
                return;
            }

            _SetValue(val);

                        #if UNITY_EDITOR
            if (m_debugBreakOnSetValue)
            {
                Debug.LogWarning("[" + Time.frameCount + "][" + this.Path() + "] " + GetType() + "::set_value to " + val + " BREAK ON SET VALUE is enabled");
                Debug.Break();
            }
                        #endif

            if (opts != PropertyEventOptions.Disable)
            {
                SendValueObjChanged();
                if (m_onValueChanged != null)
                {
                    m_onValueChanged.Invoke(val);
                }
            }
        }
Beispiel #2
0
        public void SetValue(bool val, PropertyEventOptions opts = PropertyEventOptions.SendOnChange)
        {
                        #if BT_DEBUG_UNSTRIP || UNITY_EDITOR
            if (m_debug)
            {
                Debug.Log("[" + Time.frameCount + "][" + this.Path() + "] " + GetType() + "::set_value to " + val);
            }
                        #endif

            if (opts != PropertyEventOptions.Force && val == GetValue())
            {
                EnsureValue(val);
                return;
            }

            _SetValue(val);

                        #if UNITY_EDITOR
            if (m_debugBreakOnSetValue)
            {
                Debug.LogWarning("[" + Time.frameCount + "][" + this.Path() + "] " + GetType() + "::set_value to " + val + " BREAK ON SET VALUE is enabled");
                Debug.Break();
            }
                        #endif

            if (opts != PropertyEventOptions.Disable)
            {
                SendValueChanged(val);
            }
        }
 private static bool SetThenShouldNotify <T>(this PropertyEventOptions opt, ref T prop, T val)
 {
     if (EqualityComparer <T> .Default.Equals(prop, val) && opt != PropertyEventOptions.Force)
     {
         return(false);
     }
     prop = val;
     return(opt != PropertyEventOptions.Disable);
 }
 public static bool Set <T>(this PropertyEventOptions opt, ref T prop, T val, Action <T> changeEvent)
 {
     if (!SetThenShouldNotify(opt, ref prop, val))
     {
         return(false);
     }
     changeEvent?.Invoke(val);
     return(true);
 }
 public static bool Set <T>(this PropertyEventOptions opt, ref T prop, T val, UnityEvent <T> changeEvent)
 {
     if (!SetThenShouldNotify(opt, ref prop, val))
     {
         return(false);
     }
     if (changeEvent != null)
     {
         changeEvent.Invoke(val);
     }
     return(true);
 }
        public void SetValue(float v, PropertyEventOptions opts = PropertyEventOptions.SendOnChange)
        {
#if DEBUG_UNSTRIP || UNITY_EDITOR
            if (m_debug)
            {
                Debug.Log("[" + Time.frameCount + "][" + this.Path() + "] " + GetType() + "::set_value to " + v);
            }
#endif

            if (opts != PropertyEventOptions.Force && Mathf.Approximately(v, GetValue()))
            {
                EnsureValue(v);

#if DEBUG_UNSTRIP || UNITY_EDITOR
                if (m_debug)
                {
                    Debug.Log("[" + Time.frameCount + "][" + this.Path() + "] " + GetType() + "::set_value to " + v + " will skip update (value not changed)");
                }
#endif
                return;
            }

            _SetValue(v);

                        #if UNITY_EDITOR
            if (m_debugBreakOnSetValue)
            {
                Debug.LogWarning("[" + Time.frameCount + "][" + this.Path() + "] " + GetType() + "::set_value to " + v + " BREAK ON SET VALUE is enabled");
                Debug.Break();
            }
                        #endif

            if (opts != PropertyEventOptions.Disable)
            {
                SendValueChanged(v);
            }
        }