Skip to content

Commit f6404e9

Browse files
committed
Unity 5.3 support
1 parent 9875f8d commit f6404e9

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

Scripts/Editor/Drawers/NodeEnumDrawer.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,21 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
2424
string enumName = "";
2525
if (property.enumValueIndex >= 0 && property.enumValueIndex < property.enumDisplayNames.Length) enumName = property.enumDisplayNames[property.enumValueIndex];
2626

27+
#if UNITY_2017_1_OR_NEWER
2728
// Display dropdown
2829
if (EditorGUI.DropdownButton(position, new GUIContent(enumName), FocusType.Passive)) {
2930
// Position is all wrong if we show the dropdown during the node draw phase.
3031
// Instead, add it to onLateGUI to display it later.
3132
NodeEditorWindow.current.onLateGUI += () => ShowContextMenuAtMouse(property);
3233
}
34+
#else
35+
// Display dropdown
36+
if (GUI.Button(position, new GUIContent(enumName), "MiniPopup")) {
37+
// Position is all wrong if we show the dropdown during the node draw phase.
38+
// Instead, add it to onLateGUI to display it later.
39+
NodeEditorWindow.current.onLateGUI += () => ShowContextMenuAtMouse(property);
40+
}
41+
#endif
3342
EditorGUI.EndProperty();
3443
}
3544

Scripts/Editor/NodeEditorAction.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public void Controls() {
289289
case EventType.KeyDown:
290290
if (EditorGUIUtility.editingTextField) break;
291291
else if (e.keyCode == KeyCode.F) Home();
292-
if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX) {
292+
if (IsMac()) {
293293
if (e.keyCode == KeyCode.Return) RenameSelectedNode();
294294
} else {
295295
if (e.keyCode == KeyCode.F2) RenameSelectedNode();
@@ -300,7 +300,7 @@ public void Controls() {
300300
if (e.commandName == "SoftDelete") {
301301
if (e.type == EventType.ExecuteCommand) RemoveSelectedNodes();
302302
e.Use();
303-
} else if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX && e.commandName == "Delete") {
303+
} else if (IsMac() && e.commandName == "Delete") {
304304
if (e.type == EventType.ExecuteCommand) RemoveSelectedNodes();
305305
e.Use();
306306
} else if (e.commandName == "Duplicate") {
@@ -319,6 +319,14 @@ public void Controls() {
319319
}
320320
}
321321

322+
public bool IsMac() {
323+
#if UNITY_2017_1_OR_NEWER
324+
return SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX;
325+
#else
326+
return SystemInfo.operatingSystem.StartsWith("Mac");
327+
#endif
328+
}
329+
322330
private void RecalculateDragOffsets(Event current) {
323331
dragOffset = new Vector2[Selection.objects.Length + selectedReroutes.Count];
324332
// Selected nodes

0 commit comments

Comments
 (0)