public void SetValue(string s, SettingDataType dataType)
    {
        DataType = dataType;
        switch (DataType)
        {
        case SettingDataType.Float:
            valueAsFloat = float.Parse(s);
            break;

        case SettingDataType.Long:
            valueAsLong = long.Parse(s);
            break;

        case SettingDataType.String:
            valueAsString = s;
            break;
        }
        if (OnChangedEvent == null)
        {
            OnChangedEvent = new UnityEvent();
        }
        else
        {
            OnChangedEvent.Invoke();
        }
    }
 public void ResetValue()
 {
     valueAsFloat  = 0.0f;
     valueAsLong   = 0L;
     valueAsString = string.Empty;
     OnChangedEvent.Invoke();
 }
    public void SetValue <T>(T initValue)
    {
        DataType = GetDataType(typeof(T));
        switch (DataType)
        {
        case SettingDataType.Float:
            valueAsFloat = initValue as float?;
            break;

        case SettingDataType.Long:
            valueAsLong = initValue as long?;
            break;

        case SettingDataType.String:
            valueAsString = initValue as string;
            break;
        }
        if (OnChangedEvent == null)
        {
            OnChangedEvent = new UnityEvent();
        }
        else
        {
            OnChangedEvent.Invoke();
        }
    }
        protected override void OnChanged(string propertyName, object oldValue, object newValue)
        {
            base.OnChanged(propertyName, oldValue, newValue);

            SetValueObjects();

            OnChangedEvent?.Invoke((T)this, propertyName, oldValue, newValue);
        }
예제 #5
0
    public virtual void NotifyDataChanged()
    {
        dirty = true;
        if (inTransaction)
        {
            return;
        }

        parent?.NotifyDataChanged(this);
        OnChangedEvent?.Invoke(this);
        dirty = false;
    }
예제 #6
0
        public FileWatcher(string path, OnChangedEvent onChangedEvent)
        {
            _watcher = new FileSystemWatcher
            {
                Path                  = Path.GetDirectoryName(path),
                NotifyFilter          = NotifyFilters.LastWrite,
                Filter                = Path.GetFileName(path),
                IncludeSubdirectories = false
            };

            // Add Event
            OnChanged         = onChangedEvent;
            _watcher.Changed += OnFileChanged;
        }
 public void MarkAsDirty()
 {
     OnChangedEvent?.Invoke(this);
 }
 public void AddChangedEventListener(UnityAction action)
 {
     OnChangedEvent.AddListener(action);
 }
 public float IncrementValueAsFloat(float value)
 {
     valueAsFloat = valueAsFloat.GetValueOrDefault() + value;
     OnChangedEvent.Invoke();
     return(valueAsFloat.GetValueOrDefault());
 }
 public long IncrementValueAsLong(long value)
 {
     valueAsLong = valueAsLong.GetValueOrDefault() + value;
     OnChangedEvent.Invoke();
     return(valueAsLong.GetValueOrDefault());
 }
예제 #11
0
 public void MarkAsDirty(bool value = true)
 {
     IsDirty = value;
     OnChangedEvent?.Invoke(this);
 }
예제 #12
0
 public override void OnChanged()
 {
     base.OnChanged();
     OnChangedEvent?.Invoke(this, EventArgs.Empty);
 }