File tree Expand file tree Collapse file tree 2 files changed +8
-29
lines changed Expand file tree Collapse file tree 2 files changed +8
-29
lines changed Original file line number Diff line number Diff line change @@ -17,18 +17,18 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
1717 /// <summary>
1818 /// Use this inside property setters to raise property changed events which are needed by bindingssss
1919 /// </summary>
20- /// <param name="storage">storage location where value will be set</param>
20+ /// <param name="field">field to which the value will be set</param>
2121 /// <param name="value">value you want to assign to storage</param>
2222 /// <param name="propertyName">name of the property being set</param>
2323 /// <typeparam name="T">Type of the property being set</typeparam>
2424 /// <returns>True if property was set. False if it was already equal to the given value.</returns>
25- protected bool SetProperty < T > ( ref T storage , T value , [ CallerMemberName ] string propertyName = null )
25+ protected bool SetProperty < T > ( ref T field , T value , [ CallerMemberName ] string propertyName = null )
2626 {
27- if ( EqualityComparer < T > . Default . Equals ( storage , value ) )
27+ if ( EqualityComparer < T > . Default . Equals ( field , value ) )
2828 {
2929 return false ;
3030 }
31- storage = value ;
31+ field = value ;
3232 OnPropertyChanged ( propertyName ) ;
3333 return true ;
3434 }
Original file line number Diff line number Diff line change 11using System ;
22using System . ComponentModel ;
33using System . Runtime . CompilerServices ;
4+ using Gameframe . ScriptableObjects . BindingSupport ;
45using Gameframe . ScriptableObjects . Events ;
56using UnityEngine ;
67
78namespace Gameframe . ScriptableObjects . Variables
89{
9- public class BaseVariable : ScriptableObject , INotifyPropertyChanged
10+ public class BaseVariable : BindableScriptableObject
1011 {
1112 [ SerializeField ]
1213 protected GameEvent onValueChanged ;
@@ -27,37 +28,15 @@ public GameEvent OnValueChanged
2728 /// INotifyPropertyChanged interface implemented to support Gameframe.Bindings
2829 /// </summary>
2930#region INotifyPropertyChanged
30-
31- public event PropertyChangedEventHandler PropertyChanged ;
32-
33- protected void OnPropertyChanged ( [ CallerMemberName ] string propertyName = null )
31+ protected override void OnPropertyChanged ( [ CallerMemberName ] string propertyName = null )
3432 {
35- try
36- {
37- PropertyChanged ? . Invoke ( this , new PropertyChangedEventArgs ( propertyName ) ) ;
38- }
39- catch ( Exception e )
40- {
41- Debug . LogException ( e , this ) ;
42- }
33+ base . OnPropertyChanged ( propertyName ) ;
4334 if ( onValueChanged != null )
4435 {
4536 onValueChanged . Raise ( ) ;
4637 }
4738 }
48-
4939#endregion
50-
51- protected bool SetProperty < T > ( ref T field , T value , [ CallerMemberName ] string propertyName = null )
52- {
53- if ( ! Equals ( field , value ) )
54- {
55- field = value ;
56- OnPropertyChanged ( propertyName ) ;
57- return true ;
58- }
59- return false ;
60- }
6140
6241 }
6342}
You can’t perform that action at this time.
0 commit comments