File tree Expand file tree Collapse file tree 9 files changed +53
-65
lines changed Expand file tree Collapse file tree 9 files changed +53
-65
lines changed Original file line number Diff line number Diff line change 1+ using Gameframe . ScriptableObjects . Events ;
2+ using UnityEngine ;
3+
4+ namespace Gameframe . ScriptableObjects . Variables
5+ {
6+ public class BaseVariable : ScriptableObject
7+ {
8+ [ SerializeField ]
9+ protected GameEvent onValueChanged ;
10+
11+ public GameEvent OnValueChanged
12+ {
13+ get
14+ {
15+ if ( onValueChanged == null )
16+ {
17+ onValueChanged = CreateInstance < GameEvent > ( ) ;
18+ }
19+ return onValueChanged ;
20+ }
21+ }
22+ }
23+ }
24+
Original file line number Diff line number Diff line change 1- using System . Collections ;
2- using System . Collections . Generic ;
3- using Gameframe . ScriptableObjects . Events ;
1+ using Gameframe . ScriptableObjects . Events ;
42using UnityEngine ;
53
64namespace Gameframe . ScriptableObjects . Variables
75{
86 [ CreateAssetMenu ( menuName = MenuNames . Variables + "Color" ) ]
9- public class ColorVariable : ScriptableObject , IVariable < Color >
7+ public class ColorVariable : BaseVariable , IVariable < Color >
108 {
119 [ SerializeField ]
1210 private Color value ;
@@ -25,8 +23,5 @@ public Color Value
2523 }
2624 }
2725 }
28-
29- [ SerializeField ]
30- private GameEvent onValueChanged ;
3126 }
3227}
Original file line number Diff line number Diff line change 1- using System . Collections ;
2- using System . Collections . Generic ;
3- using Gameframe . ScriptableObjects . Events ;
4- using UnityEngine ;
1+ using UnityEngine ;
52
63namespace Gameframe . ScriptableObjects . Variables
74{
85 [ CreateAssetMenu ( menuName = MenuNames . Variables + "Float" ) ]
9- public class FloatVariable : ScriptableObject , IVariable < float >
6+ public class FloatVariable : BaseVariable , IVariable < float >
107 {
118 [ SerializeField ]
129 private float value ;
@@ -25,8 +22,5 @@ public float Value
2522 }
2623 }
2724 }
28-
29- [ SerializeField ]
30- private GameEvent onValueChanged ;
3125 }
3226}
Original file line number Diff line number Diff line change 55namespace Gameframe . ScriptableObjects . Variables
66{
77 [ CreateAssetMenu ( menuName = MenuNames . Variables + "GameObject" ) ]
8- public class GameObjectVariable : ScriptableObject , IVariable < GameObject >
8+ public class GameObjectVariable : BaseVariable , IVariable < GameObject >
99 {
1010 [ SerializeField ]
1111 private bool clearOnEnable = false ;
1212
1313 [ SerializeField ]
1414 private GameObject gameObject = null ;
1515
16- [ SerializeField ]
17- private GameEvent onValueChanged = null ;
18-
19- [ SerializeField ]
20- private UnityEvent valueChanged = new UnityEvent ( ) ;
21- public UnityEvent OnValueChanged => valueChanged ;
22-
2316 public GameObject Value
2417 {
2518 get => gameObject ;
@@ -28,8 +21,10 @@ public GameObject Value
2821 if ( gameObject != value )
2922 {
3023 gameObject = value ;
31- valueChanged . Invoke ( ) ;
32- onValueChanged ? . Raise ( ) ;
24+ if ( onValueChanged != null )
25+ {
26+ onValueChanged . Raise ( ) ;
27+ }
3328 }
3429 }
3530 }
@@ -41,15 +36,6 @@ private void OnEnable()
4136 Value = null ;
4237 }
4338 }
44-
45- public void RaisedPropertyChanged ( )
46- {
47- onValueChanged . Raise ( ) ;
48- }
49-
50- public void Clear ( )
51- {
52- Value = null ;
53- }
39+
5440 }
5541}
Original file line number Diff line number Diff line change 1- using System . Collections ;
2- using System . Collections . Generic ;
3- using Gameframe . ScriptableObjects . Events ;
4- using UnityEngine ;
1+ using UnityEngine ;
52
63namespace Gameframe . ScriptableObjects . Variables
74{
85 [ CreateAssetMenu ( menuName = MenuNames . Variables + "Int" ) ]
9- public class IntVariable : ScriptableObject , IVariable < int >
6+ public class IntVariable : BaseVariable , IVariable < int >
107 {
118 [ SerializeField ]
129 private int value ;
@@ -25,8 +22,5 @@ public int Value
2522 }
2623 }
2724 }
28-
29- [ SerializeField ]
30- private GameEvent onValueChanged ;
3125 }
3226}
Original file line number Diff line number Diff line change 1- using System . Collections ;
2- using System . Collections . Generic ;
3- using Gameframe . ScriptableObjects . Events ;
4- using UnityEngine ;
1+ using UnityEngine ;
52
63namespace Gameframe . ScriptableObjects . Variables
74{
85 [ CreateAssetMenu ( menuName = MenuNames . Variables + "String" ) ]
9- public class StringVariable : ScriptableObject , IVariable < string >
6+ public class StringVariable : BaseVariable , IVariable < string >
107 {
118 [ SerializeField ]
129 private string value ;
@@ -25,8 +22,5 @@ public string Value
2522 }
2623 }
2724 }
28-
29- [ SerializeField ]
30- private GameEvent onValueChanged ;
3125 }
3226}
Original file line number Diff line number Diff line change 1- using System . Collections ;
2- using System . Collections . Generic ;
3- using Gameframe . ScriptableObjects . Events ;
4- using UnityEngine ;
1+ using UnityEngine ;
52
63namespace Gameframe . ScriptableObjects . Variables
74{
85 [ CreateAssetMenu ( menuName = MenuNames . Variables + "Vector2" ) ]
9- public class Vector2Variable : ScriptableObject , IVariable < Vector2 >
6+ public class Vector2Variable : BaseVariable , IVariable < Vector2 >
107 {
118 [ SerializeField ]
129 private Vector2 value ;
@@ -25,8 +22,5 @@ public Vector2 Value
2522 }
2623 }
2724 }
28-
29- [ SerializeField ]
30- private GameEvent onValueChanged ;
3125 }
3226}
Original file line number Diff line number Diff line change 1- using Gameframe . ScriptableObjects . Events ;
2- using UnityEngine ;
1+ using UnityEngine ;
32
43namespace Gameframe . ScriptableObjects . Variables
54{
65 [ CreateAssetMenu ( menuName = MenuNames . Variables + "Vector3" ) ]
7- public class Vector3Variable : ScriptableObject , IVariable < Vector3 >
6+ public class Vector3Variable : BaseVariable , IVariable < Vector3 >
87 {
98 [ SerializeField ]
109 private Vector3 value ;
@@ -23,8 +22,5 @@ public Vector3 Value
2322 }
2423 }
2524 }
26-
27- [ SerializeField ]
28- private GameEvent onValueChanged ;
2925 }
3026}
You can’t perform that action at this time.
0 commit comments