コード例 #1
0
 /// <summary>
 /// Constructs a new Property
 /// </summary>
 /// <param name="owner">The owner of the property</param>
 /// <param name="defaultValue">The default and initial value of the property</param>
 /// <param name="onValueChanged">A callback for when the property value changes</param>
 public Property(TOwner owner, TValue defaultValue, OnValueChangedDelegate onValueChanged)
 {
     Owner        = owner;
     DefaultValue = defaultValue;
     LoadValue(defaultValue);
     OnValueChanged = onValueChanged;
 }
コード例 #2
0
ファイル: DatasackStack.cs プロジェクト: pulkit1011/makegeo
 public void PushOnChanged(OnValueChangedDelegate callback)
 {
     if (OnChangedStack == null)
     {
         OnChangedStack = new Stack <OnValueChangedDelegate>();
     }
     OnChangedStack.Push(OnChanged);
     OnChanged = callback;
 }
コード例 #3
0
ファイル: Datasack.cs プロジェクト: kurtdekker/datasacks
    public void    Poke()
    {
        if (OnChanged != null)
        {
            OnChanged.Invoke(this);
        }

        var call = OnChangedOnceOnly;

        if (call != null)
        {
            OnChangedOnceOnly = null;
            call(this);
        }
    }
コード例 #4
0
        void AddIntSlider(SerializedProperty property, string text, string tooltip, OnValueChangedDelegate <int> onChange = null, int min = 0, int max = int.MaxValue)
        {
            Rect ourRect = EditorGUILayout.BeginHorizontal();

            EditorGUI.BeginProperty(ourRect, GUIContent.none, property);

            var orgValue = property.intValue;
            var newValue = EditorGUILayout.IntSlider(new GUIContent(text, tooltip), orgValue, min, max);

            if (onChange != null && orgValue != newValue)
            {
                newValue = onChange(orgValue, newValue);
            }

            property.intValue = newValue;

            EditorGUI.EndProperty();
            EditorGUILayout.EndHorizontal();
        }
コード例 #5
0
 /// <summary>
 /// 状態が変化した際に呼び出されるデリゲートを削除する
 /// </summary>
 /// <param name="tOnValueChangedDelegate">デリゲートメソッド</param>
 public void RemoveOnValueChanged(OnValueChangedDelegate tOnValueChangedDelegate)
 {
     onValueChangedDelegate -= tOnValueChangedDelegate;
 }
コード例 #6
0
 /// <summary>
 /// 状態が変化した際に呼び出されるデリゲートを追加する
 /// </summary>
 /// <param name="tOnValueChangedDelegate">デリゲートメソッド</param>
 public void AddOnValueChanged(OnValueChangedDelegate tOnValueChangedDelegate)
 {
     onValueChangedDelegate += tOnValueChangedDelegate;
 }
コード例 #7
0
 public void Unsubscribe(OnValueChangedDelegate d)
 {
     if(del != null)
         del -= d;
 }
コード例 #8
0
 public void Subscribe(OnValueChangedDelegate d)
 {
     Subscribe(d, true);
 }
コード例 #9
0
    public void Subscribe(OnValueChangedDelegate d, bool callNow)
    {
        if(del == null)
            del = d;
        else
            del += d;

        if(callNow) d(value);
    }
コード例 #10
0
 public void RegisterOnHealthValueChangedEventListener(OnValueChangedDelegate OnValueChangedDelegate)
 {
     this.OnHealthValueChangedEvent += OnValueChangedDelegate;
     /// Initialize the added event by manually calling it
     OnValueChangedDelegate.Invoke(this.CurrentHealth.GetValue(), this.CurrentHealth.GetValue());
 }
コード例 #11
0
        void AddFloatSlider(SerializedProperty property, string text, string tooltip, OnValueChangedDelegate <float> onChange = null, float factor = 1f, float min = 0, float max = float.MaxValue)
        {
            Rect ourRect = EditorGUILayout.BeginHorizontal();

            EditorGUI.BeginProperty(ourRect, GUIContent.none, property);

            var orgValue = property.floatValue * factor;
            var newValue = EditorGUILayout.Slider(new GUIContent(text, tooltip), orgValue, min * factor, max * factor) / factor;

            if (onChange != null && orgValue != newValue)
            {
                newValue = onChange(orgValue, newValue);
            }

            property.floatValue = newValue;

            EditorGUI.EndProperty();
            EditorGUILayout.EndHorizontal();
        }
コード例 #12
0
        void AddEnumPopup(SerializedProperty property, string text, string tooltip, Type typeOfEnum, OnValueChangedDelegate <int> onChange = null)
        {
            Rect ourRect = EditorGUILayout.BeginHorizontal();

            EditorGUI.BeginProperty(ourRect, GUIContent.none, property);

            int selectionFromInspector = property.intValue;

            string[] enumNamesList = System.Enum.GetNames(typeOfEnum);

            var actualSelected = EditorGUILayout.Popup(text, selectionFromInspector, enumNamesList);

            if (onChange != null && actualSelected != property.intValue)
            {
                actualSelected = onChange(property.intValue, actualSelected);
            }

            property.intValue = actualSelected;

            EditorGUI.EndProperty();
            EditorGUILayout.EndHorizontal();
        }
コード例 #13
0
 public FloatVariable(float startValue, OnValueChangedDelegate onValueChanged = null)
 {
     Value          = startValue;
     OnValueChanged = onValueChanged;
 }
コード例 #14
0
 /// <summary>
 /// Constructs a new Property
 /// </summary>
 /// <param name="defaultValue">The default and initial value of the property</param>
 /// <param name="onValueChanged">A callback for when the property value changes</param>
 public Property(TValue defaultValue, OnValueChangedDelegate onValueChanged = null) : this(default(TOwner), defaultValue, onValueChanged)
 {
 }
コード例 #15
0
 /// <summary>
 /// Constructs a new Property
 /// </summary>
 /// <param name="owner">The owner of the property</param>
 /// <param name="onValueChanged">A callback for when the property value changes</param>
 public Property(TOwner owner, OnValueChangedDelegate onValueChanged = null) : this(owner, default(TValue), onValueChanged)
 {
 }
コード例 #16
0
        void AddBoolProperty(SerializedProperty property, string text, string tooltip, OnValueChangedDelegate <bool> onChange = null)
        {
            Rect ourRect = EditorGUILayout.BeginHorizontal();

            EditorGUI.BeginProperty(ourRect, GUIContent.none, property);

            var orgValue = property.boolValue;
            var newValue = EditorGUILayout.Toggle(new GUIContent(text, tooltip), orgValue);

            if (onChange != null && orgValue != newValue)
            {
                newValue = onChange(orgValue, newValue);
            }

            property.boolValue = newValue;

            EditorGUI.EndProperty();
            EditorGUILayout.EndHorizontal();
        }
コード例 #17
0
        public HealthSystem(CoreInteractiveObject AssociatedInteractiveObject, HealthSystemDefinition HealthSystemDefinition, OnValueChangedDelegate OnHealthValueChangedAction = null)
        {
            this.AssociatedInteractiveObject = AssociatedInteractiveObject;
            this.HealthSystemDefinition      = HealthSystemDefinition;

            /// By default, the constructor OnValueChangedDelegate is registered to OnValueChangedEvent
            if (OnHealthValueChangedAction != null)
            {
                this.OnHealthValueChangedEvent += OnHealthValueChangedAction;
            }

            this.CurrentHealth = new FloatVariable(this.HealthSystemDefinition.StartHealth, this.OnHealthValueChanged);
        }