Skip to content

Commit 3c37d86

Browse files
committed
fix: Link Override
Override Link data implementen in Link.cs. Inspector Group Button is connected to link Property
1 parent 2769268 commit 3c37d86

38 files changed

+450
-217
lines changed

Editor/Scripts/Inspector/Cylinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ public override VisualElement CreateInspectorGUI()
1616
var container = new VisualElement();
1717

1818
var groupControl = new PropertyGroup("Control");
19+
groupControl.AddLinkOverride(component);
1920
var hStack = new StackHorizontal();
2021
hStack.Add(new PushButton("Minus").BindProperty(component.Minus));
2122
hStack.Add(new PushButton("Plus").BindProperty(component.Plus));
2223
groupControl.Add(hStack);
23-
groupControl.AddForceOption(component, new IProperty[]{component.Minus, component.Plus});
2424

2525
var groupStatus = new PropertyGroup("Status");
2626
groupStatus.Add(new ProgressBar("Progress"){bindingPath = "_progress._value", ShowLimits = true});

Editor/Scripts/Inspector/DrivePosition.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ public override VisualElement CreateInspectorGUI()
1717
var container = new VisualElement();
1818

1919
var groupControl = new PropertyGroup("Control");
20+
groupControl.AddLinkOverride(component);
2021
groupControl.Add(new FloatField("Target").BindProperty(component.Target).AlignedField());
21-
groupControl.AddForceOption(component, new IProperty[]{component.Target});
22-
22+
2323
var groupStatus = new PropertyGroup("Status");
2424
groupStatus.Add(new LampField("Is Active", Color.green).BindProperty(component.IsActive).AlignedField());
2525
groupStatus.Add(new FloatField("Value"){isReadOnly = true}.BindProperty(component.Value).AlignedField());

Editor/Scripts/Inspector/DriveSimple.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ public override VisualElement CreateInspectorGUI()
1717
var container = new VisualElement();
1818

1919
var groupControl = new PropertyGroup("Control");
20-
groupControl.Add(new FloatField("Target").BindProperty(component.Target).AlignedField());
20+
groupControl.AddLinkOverride(component);
2121
var hStack = new StackHorizontal();
2222
hStack.Add(new ToggleButton("Backward").BindProperty(component.Backward));
2323
hStack.Add(new ToggleButton("Forward").BindProperty(component.Forward));
2424
groupControl.Add(hStack);
25-
groupControl.AddForceOption(component, new IProperty[]{component.Backward, component.Forward});
2625

2726
var groupStatus = new PropertyGroup("Status");
2827
groupStatus.Add(new LampField("Is Active", Color.green).BindProperty(component.IsActive).AlignedField());

Editor/Scripts/Inspector/DriveSpeed.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public override VisualElement CreateInspectorGUI()
1717
var container = new VisualElement();
1818

1919
var groupControl = new PropertyGroup("Control");
20+
groupControl.AddLinkOverride(component);
2021
groupControl.Add(new FloatField("Target").BindProperty(component.Target).AlignedField());
21-
groupControl.AddForceOption(component, new IProperty[]{component.Target});
2222

2323
var groupStatus = new PropertyGroup("Status");
2424
groupStatus.Add(new LampField("Is Active", Color.green).BindProperty(component.IsActive).AlignedField());

Editor/Scripts/Inspector/Lamp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public override VisualElement CreateInspectorGUI()
1818
var container = new VisualElement();
1919

2020
var groupControl = new PropertyGroup("Control");
21+
groupControl.AddLinkOverride(component);
2122
groupControl.Add(new ToggleButton("Signal").BindProperty(component.Value).AlignedField());
22-
groupControl.AddForceOption(component, new IProperty[]{component.Value});
2323

2424
var groupStatus = new PropertyGroup("Status");
2525
groupStatus.Add(new LampField("Value", Color.green).BindProperty(component.Value).AlignedField());

Editor/Scripts/Inspector/Lock.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public override VisualElement CreateInspectorGUI()
1717
var container = new VisualElement();
1818

1919
var groupControl = new PropertyGroup("Control");
20+
groupControl.AddLinkOverride(component);
2021
groupControl.Add(new ToggleButton("Lock").BindProperty(component.LockSignal));
21-
groupControl.AddForceOption(component, new IProperty[]{component.LockSignal});
2222

2323
var groupStatus = new PropertyGroup("Status");
2424
groupStatus.Add(new LampField("Lock", Color.green).BindProperty(component.LockSignal).AlignedField());
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using OC.Communication;
2+
using OC.VisualElements;
3+
using UnityEngine.UIElements;
4+
5+
namespace OC.Editor
6+
{
7+
public class OverrideController : ToggleButton
8+
{
9+
private readonly VisualElement _target;
10+
private bool _override;
11+
12+
public OverrideController(IDevice device, VisualElement target)
13+
{
14+
_target = target;
15+
label = "Override";
16+
17+
this.BindProperty(device.Link.Override);
18+
19+
device.Link.Override.Subscribe(OnOverrideChanged);
20+
}
21+
22+
private void OnOverrideChanged(bool @override)
23+
{
24+
_target.SetEnabled(@override);
25+
}
26+
}
27+
}

Editor/Scripts/Inspector/OverrideController.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/Scripts/Inspector/SensorAnalog.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public override VisualElement CreateInspectorGUI()
1616
var container = new VisualElement();
1717

1818
var groupControl = new PropertyGroup("Control");
19+
groupControl.AddLinkOverride(component);
1920
groupControl.Add(new FloatField("Value").BindProperty(component.Value).AlignedField());
20-
groupControl.AddForceOption(component, new IProperty[]{component.Value});
2121

2222
var groupStatus = new PropertyGroup("Status");
2323
groupStatus.Add(new FloatField("Value"){isReadOnly = true}.BindProperty(component.Value).AlignedField());

Editor/Scripts/Inspector/SensorBinary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public override VisualElement CreateInspectorGUI()
1818
var container = new VisualElement();
1919

2020
var groupControl = new PropertyGroup("Control");
21+
groupControl.AddLinkOverride(component);
2122
groupControl.Add(new ToggleButton("Collision").BindProperty(component.State).AlignedField());
22-
groupControl.AddForceOption(component, new IProperty[]{component.State});
2323

2424
var groupStatus = new PropertyGroup("Status");
2525
groupStatus.Add(new LampField("Collision", Color.yellow).BindProperty(component.Collision).AlignedField());

0 commit comments

Comments
 (0)