1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-20 17:26:02 +08:00

Moved IsMac to NodeEditorUtilities

This commit is contained in:
Thor Brigsted 2019-07-24 10:25:29 +02:00
parent 891ecebc3f
commit bb847a3044
2 changed files with 12 additions and 12 deletions

View File

@ -299,7 +299,7 @@ namespace XNodeEditor {
case EventType.KeyDown: case EventType.KeyDown:
if (EditorGUIUtility.editingTextField) break; if (EditorGUIUtility.editingTextField) break;
else if (e.keyCode == KeyCode.F) Home(); else if (e.keyCode == KeyCode.F) Home();
if (IsMac()) { if (NodeEditorUtilities.IsMac()) {
if (e.keyCode == KeyCode.Return) RenameSelectedNode(); if (e.keyCode == KeyCode.Return) RenameSelectedNode();
} else { } else {
if (e.keyCode == KeyCode.F2) RenameSelectedNode(); if (e.keyCode == KeyCode.F2) RenameSelectedNode();
@ -310,7 +310,7 @@ namespace XNodeEditor {
if (e.commandName == "SoftDelete") { if (e.commandName == "SoftDelete") {
if (e.type == EventType.ExecuteCommand) RemoveSelectedNodes(); if (e.type == EventType.ExecuteCommand) RemoveSelectedNodes();
e.Use(); e.Use();
} else if (IsMac() && e.commandName == "Delete") { } else if (NodeEditorUtilities.IsMac() && e.commandName == "Delete") {
if (e.type == EventType.ExecuteCommand) RemoveSelectedNodes(); if (e.type == EventType.ExecuteCommand) RemoveSelectedNodes();
e.Use(); e.Use();
} else if (e.commandName == "Duplicate") { } else if (e.commandName == "Duplicate") {
@ -335,14 +335,6 @@ namespace XNodeEditor {
} }
} }
public bool IsMac() {
#if UNITY_2017_1_OR_NEWER
return SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX;
#else
return SystemInfo.operatingSystem.StartsWith("Mac");
#endif
}
private void RecalculateDragOffsets(Event current) { private void RecalculateDragOffsets(Event current) {
dragOffset = new Vector2[Selection.objects.Length + selectedReroutes.Count]; dragOffset = new Vector2[Selection.objects.Length + selectedReroutes.Count];
// Selected nodes // Selected nodes

View File

@ -9,7 +9,7 @@ using UnityEngine;
using Object = UnityEngine.Object; using Object = UnityEngine.Object;
namespace XNodeEditor { namespace XNodeEditor {
/// <summary> A set of editor-only utilities and extensions for UnityNodeEditorBase </summary> /// <summary> A set of editor-only utilities and extensions for xNode </summary>
public static class NodeEditorUtilities { public static class NodeEditorUtilities {
/// <summary>C#'s Script Icon [The one MonoBhevaiour Scripts have].</summary> /// <summary>C#'s Script Icon [The one MonoBhevaiour Scripts have].</summary>
@ -25,7 +25,7 @@ namespace XNodeEditor {
public static bool GetAttrib<T>(object[] attribs, out T attribOut) where T : Attribute { public static bool GetAttrib<T>(object[] attribs, out T attribOut) where T : Attribute {
for (int i = 0; i < attribs.Length; i++) { for (int i = 0; i < attribs.Length; i++) {
if (attribs[i] is T){ if (attribs[i] is T) {
attribOut = attribs[i] as T; attribOut = attribs[i] as T;
return true; return true;
} }
@ -84,6 +84,14 @@ namespace XNodeEditor {
return true; return true;
} }
public static bool IsMac() {
#if UNITY_2017_1_OR_NEWER
return SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX;
#else
return SystemInfo.operatingSystem.StartsWith("Mac");
#endif
}
/// <summary> Returns true if this can be casted to <see cref="Type"/></summary> /// <summary> Returns true if this can be casted to <see cref="Type"/></summary>
public static bool IsCastableTo(this Type from, Type to) { public static bool IsCastableTo(this Type from, Type to) {
if (to.IsAssignableFrom(from)) return true; if (to.IsAssignableFrom(from)) return true;