File tree 2 files changed +8
-29
lines changed
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
17
17
/// <summary>
18
18
/// Use this inside property setters to raise property changed events which are needed by bindingssss
19
19
/// </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>
21
21
/// <param name="value">value you want to assign to storage</param>
22
22
/// <param name="propertyName">name of the property being set</param>
23
23
/// <typeparam name="T">Type of the property being set</typeparam>
24
24
/// <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 )
26
26
{
27
- if ( EqualityComparer < T > . Default . Equals ( storage , value ) )
27
+ if ( EqualityComparer < T > . Default . Equals ( field , value ) )
28
28
{
29
29
return false ;
30
30
}
31
- storage = value ;
31
+ field = value ;
32
32
OnPropertyChanged ( propertyName ) ;
33
33
return true ;
34
34
}
Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . ComponentModel ;
3
3
using System . Runtime . CompilerServices ;
4
+ using Gameframe . ScriptableObjects . BindingSupport ;
4
5
using Gameframe . ScriptableObjects . Events ;
5
6
using UnityEngine ;
6
7
7
8
namespace Gameframe . ScriptableObjects . Variables
8
9
{
9
- public class BaseVariable : ScriptableObject , INotifyPropertyChanged
10
+ public class BaseVariable : BindableScriptableObject
10
11
{
11
12
[ SerializeField ]
12
13
protected GameEvent onValueChanged ;
@@ -27,37 +28,15 @@ public GameEvent OnValueChanged
27
28
/// INotifyPropertyChanged interface implemented to support Gameframe.Bindings
28
29
/// </summary>
29
30
#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 )
34
32
{
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 ) ;
43
34
if ( onValueChanged != null )
44
35
{
45
36
onValueChanged . Raise ( ) ;
46
37
}
47
38
}
48
-
49
39
#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
- }
61
40
62
41
}
63
42
}
You can’t perform that action at this time.
0 commit comments