Skip to content

Commit 2cd3118

Browse files
authored
Merge pull request #105 from OpenCommissioning/hotfix_unity_6_4
Hotfix unity 6 4
2 parents 5f0cb33 + c8093ef commit 2cd3118

57 files changed

Lines changed: 450 additions & 93 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Editor/Scripts/Hierarchy/ProjectInspectorWindow.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,11 @@ private void ApplySearchFilter(string filter)
253253

254254
private void ResetOverride()
255255
{
256+
#if UNITY_6000_3_OR_NEWER
257+
var devices = FindObjectsByType<MonoBehaviour>(FindObjectsSortMode.InstanceID).OfType<IDevice>().ToList();
258+
#else
256259
var devices = FindObjectsOfType<MonoBehaviour>().OfType<IDevice>().ToList();
260+
#endif
257261
foreach (var item in devices.Where(item => item.Override.Value))
258262
{
259263
item.Override.Value = false;

Editor/Scripts/Inspector/Cylinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public override VisualElement CreateInspectorGUI()
2323
groupControl.Add(hStack);
2424

2525
var groupStatus = new PropertyGroup("Status");
26-
groupStatus.Add(new ProgressBar("Progress"){bindingPath = "_progress._value", ShowLimits = true});
26+
groupStatus.Add(new OCProgressBar("Progress"){bindingPath = "_progress._value", ShowLimits = true});
2727
groupStatus.Add(new FloatField("Value"){isReadOnly = true, bindingPath = "_value._value"}.AlignedField());
2828

2929
var groupSettings = new PropertyGroup("Settings");

Editor/Scripts/SceneInteractionTool.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@ public class SceneInteractionTool : EditorTool
1919
private readonly List<Interaction> _hitInteractions = new ();
2020
private int _hitsCount;
2121
private Interaction _activeInteraction;
22-
private int[] _outlineRenderers = Array.Empty<int>();
2322
private const string ICON = "d_EventTrigger Icon";
2423
private readonly GUIStyle _roundedBoxStyle = new ();
2524

25+
#if UNITY_6000_4_OR_NEWER
26+
private EntityId[] _outlineRenderers = Array.Empty<EntityId>();
27+
#else
28+
private int[] _outlineRenderers = Array.Empty<int>();
29+
#endif
30+
2631
[Shortcut("Scene Interaction Tool", typeof(SceneView), KeyCode.I)]
2732
private static void SceneViewInteractionShortcut()
2833
{
@@ -199,11 +204,21 @@ private void RayCast(Event currentEvent)
199204
_activeInteraction = _hitInteractions.First();
200205
PointerEnterEvent(_activeInteraction);
201206

207+
208+
#if UNITY_6000_4_OR_NEWER
209+
_outlineRenderers = new EntityId[_activeInteraction.Renderers.Count];
210+
for (var i = 0; i < _activeInteraction.Renderers.Count; i++)
211+
{
212+
_outlineRenderers[i] = _activeInteraction.Renderers[i].GetEntityId();
213+
}
214+
#else
202215
_outlineRenderers = new int[_activeInteraction.Renderers.Count];
203216
for (var i = 0; i < _activeInteraction.Renderers.Count; i++)
204217
{
205218
_outlineRenderers[i] = _activeInteraction.Renderers[i].GetInstanceID();
206219
}
220+
#endif
221+
207222
}
208223

209224
private void ResetHit()

Editor/Scripts/Snapping/SnappingTool.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ private static void SnappingToolShortcut()
3434

3535
public override void OnActivated()
3636
{
37+
#if UNITY_6000_3_OR_NEWER
38+
_sceneSnappingPoints = FindObjectsByType<SnappingPoint>(FindObjectsSortMode.InstanceID).ToList();
39+
#else
3740
_sceneSnappingPoints = FindObjectsOfType<SnappingPoint>().ToList();
41+
#endif
3842
}
3943

4044
public override void OnWillBeDeactivated()

Editor/Scripts/VisualElements/LampField.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
namespace OC.Editor
77
{
8+
#if UNITY_6000_3_OR_NEWER
9+
[UxmlElement("OCEditorLampField")]
10+
public partial class LampField : BaseField<bool>
11+
{
12+
#else
813
public class LampField : BaseField<bool>
914
{
1015
public new class UxmlFactory : UxmlFactory<LampField, UxmlTraits> { }
@@ -25,7 +30,7 @@ public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext
2530
baseFieldLamp.LampShape = _lampShape.GetValueFromBag(bag, cc);
2631
}
2732
}
28-
33+
#endif
2934
public override bool value
3035
{
3136
get => base.value;
@@ -36,6 +41,9 @@ public override bool value
3641
}
3742
}
3843

44+
#if UNITY_6000_3_OR_NEWER
45+
[UxmlAttribute("Lamp-Shape")]
46+
#endif
3947
public InspectorLampShape LampShape
4048
{
4149
get => _lampShape;

Editor/Scripts/VisualElements/ProgressBar.cs renamed to Editor/Scripts/VisualElements/OCProgressBar.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
namespace OC.Editor
66
{
7+
#if UNITY_6000_3_OR_NEWER
8+
[UxmlElement("OCEditorProgressBarWithLimits")]
9+
public partial class OCProgressBar : UnityEngine.UIElements.ProgressBar
10+
{
11+
#else
712
public class ProgressBar : UnityEngine.UIElements.ProgressBar
813
{
914
public new class UxmlFactory : UxmlFactory<ProgressBar, UxmlTraits> { }
@@ -28,7 +33,11 @@ public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext
2833
progressBar.ColorBackground = _colorBackground.GetValueFromBag(bag, cc);
2934
}
3035
}
31-
36+
#endif
37+
38+
#if UNITY_6000_3_OR_NEWER
39+
[UxmlAttribute("Color-Bar")]
40+
#endif
3241
public Color ColorBar
3342
{
3443
get => _colorBar;
@@ -39,6 +48,9 @@ public Color ColorBar
3948
}
4049
}
4150

51+
#if UNITY_6000_3_OR_NEWER
52+
[UxmlAttribute("Color-Background")]
53+
#endif
4254
public Color ColorBackground
4355
{
4456
get => _colorBackground;
@@ -48,7 +60,10 @@ public Color ColorBackground
4860
_colorBackground = value;
4961
}
5062
}
51-
63+
64+
#if UNITY_6000_3_OR_NEWER
65+
[UxmlAttribute("Show-Limits")]
66+
#endif
5267
public bool ShowLimits
5368
{
5469
get => _showLimits;
@@ -101,9 +116,9 @@ public bool Max
101116
private const string LIMIT_USS_CLASS_NAME = "progress-bar__limit";
102117
private const string LIMIT_ACTIVE_USS_CLASS_NAME = "progress-bar__limit-active";
103118

104-
public ProgressBar() : this(""){}
119+
public OCProgressBar() : this(""){}
105120

106-
public ProgressBar(string title)
121+
public OCProgressBar(string title)
107122
{
108123
this.title = title;
109124
styleSheets.Add(Resources.Load<StyleSheet>(USS));
File renamed without changes.

Editor/Scripts/VisualElements/PropertyGroup.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
namespace OC.Editor
88
{
9+
#if UNITY_6000_3_OR_NEWER
10+
[UxmlElement("OCEditorPropertyGroup")]
11+
public partial class PropertyGroup : VisualElement
12+
{
13+
#else
914
public class PropertyGroup : VisualElement
1015
{
1116
public new class UxmlFactory : UxmlFactory<PropertyGroup, UxmlTraits> { }
@@ -26,7 +31,11 @@ public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext
2631
group.Label = _label.GetValueFromBag(bag, cc);
2732
}
2833
}
34+
#endif
2935

36+
#if UNITY_6000_3_OR_NEWER
37+
[UxmlAttribute("Label")]
38+
#endif
3039
public string Label
3140
{
3241
get => _labelElement.text;

Editor/Scripts/VisualElements/PushButton.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
namespace OC.Editor
66
{
7+
#if UNITY_6000_4_OR_NEWER
8+
[UxmlElement]
9+
public partial class PushButton : BaseField<bool>
10+
{
11+
#else
712
public class PushButton : BaseField<bool>
813
{
914
public new class UxmlFactory : UxmlFactory<PushButton, UxmlTraits> { }
@@ -14,6 +19,7 @@ public UxmlTraits()
1419
focusable.defaultValue = false;
1520
}
1621
}
22+
#endif
1723

1824
private const string USS = "StyleSheet/oc-inspector";
1925
private const string USS_CLASS_NAME = "button";

Editor/Scripts/VisualElements/ToggleButton.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
namespace OC.Editor
55
{
6+
#if UNITY_6000_4_OR_NEWER
7+
[UxmlElement]
8+
public partial class ToggleButton : Toggle
9+
{
10+
#else
11+
612
public class ToggleButton : Toggle
713
{
814
public new class UxmlFactory : UxmlFactory<ToggleButton, UxmlTraits> { }
@@ -13,6 +19,7 @@ public UxmlTraits()
1319
focusable.defaultValue = false;
1420
}
1521
}
22+
#endif
1623

1724
private const string USS = "StyleSheet/oc-inspector";
1825
private const string USS_CLASS_NAME = "button";

0 commit comments

Comments
 (0)