Skip to content

Commit 37020e5

Browse files
authored
Merge pull request #96 from OpenCommissioning/extensibility
fix: UnityEvent extension
2 parents 49895f4 + da79e17 commit 37020e5

File tree

5 files changed

+15
-0
lines changed

5 files changed

+15
-0
lines changed

Editor/Scripts/Inspector/DrivePosition.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public override VisualElement CreateInspectorGUI()
2828

2929
var groupEvents = new PropertyGroup("Events");
3030
groupEvents.Add(new PropertyField{bindingPath = "OnActiveChanged"});
31+
groupEvents.Add(new PropertyField{bindingPath = "OnValueChanged"});
3132

3233
container.Add(groupControl);
3334
container.Add(groupStatus);

Editor/Scripts/Inspector/DriveSimple.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public override VisualElement CreateInspectorGUI()
3333

3434
var groupEvents = new PropertyGroup("Events");
3535
groupEvents.Add(new PropertyField{bindingPath = "OnActiveChanged"});
36+
groupEvents.Add(new PropertyField{bindingPath = "OnValueChanged"});
3637

3738
container.Add(groupControl);
3839
container.Add(groupStatus);

Editor/Scripts/Inspector/DriveSpeed.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public override VisualElement CreateInspectorGUI()
2828

2929
var groupEvents = new PropertyGroup("Events");
3030
groupEvents.Add(new PropertyField{bindingPath = "OnActiveChanged"});
31+
groupEvents.Add(new PropertyField{bindingPath = "OnValueChanged"});
3132

3233
container.Add(groupControl);
3334
container.Add(groupStatus);

Runtime/Scripts/Components/Drive.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public abstract class Drive : Actor, IDevice, IMetadataAsset, ICustomInspector,
2020
public IPropertyReadOnly<DriveState> State => _stateObserver.State;
2121

2222
public UnityEvent<bool> OnActiveChanged;
23+
public UnityEvent<float> OnValueChanged;
2324

2425
[SerializeField]
2526
protected Property<bool> _override = new (false);
@@ -32,11 +33,13 @@ public abstract class Drive : Actor, IDevice, IMetadataAsset, ICustomInspector,
3233
protected void OnEnable()
3334
{
3435
_stateObserver.IsActive.Subscribe(OnActiveChanged.Invoke);
36+
_value.Subscribe(OnValueChanged.Invoke);
3537
}
3638

3739
protected void OnDisable()
3840
{
3941
_stateObserver.IsActive.Unsubscribe(OnActiveChanged.Invoke);
42+
_value.Unsubscribe(OnValueChanged.Invoke);
4043
}
4144

4245
protected void Start()

Samples/Demo/0.1 Devices.unity

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,9 @@ MonoBehaviour:
551551
OnActiveChanged:
552552
m_PersistentCalls:
553553
m_Calls: []
554+
OnValueChanged:
555+
m_PersistentCalls:
556+
m_Calls: []
554557
_override:
555558
_value: 0
556559
_link:
@@ -2322,6 +2325,9 @@ MonoBehaviour:
23222325
OnActiveChanged:
23232326
m_PersistentCalls:
23242327
m_Calls: []
2328+
OnValueChanged:
2329+
m_PersistentCalls:
2330+
m_Calls: []
23252331
_override:
23262332
_value: 0
23272333
_link:
@@ -5026,6 +5032,9 @@ MonoBehaviour:
50265032
OnActiveChanged:
50275033
m_PersistentCalls:
50285034
m_Calls: []
5035+
OnValueChanged:
5036+
m_PersistentCalls:
5037+
m_Calls: []
50295038
_override:
50305039
_value: 0
50315040
_link:

0 commit comments

Comments
 (0)