From 55981882577cb8eca05a81ad90bf2b962293d8ab Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Tue, 2 Jan 2018 02:23:44 +0700 Subject: [PATCH] Fix Unity 5.6 warning --- Assets/IsoTools/Docs/CHANGELOG.md | 4 + .../Scripts/Internal/Editor/IsoEditorUtils.cs | 80 +++++++++++++------ 2 files changed, 61 insertions(+), 23 deletions(-) diff --git a/Assets/IsoTools/Docs/CHANGELOG.md b/Assets/IsoTools/Docs/CHANGELOG.md index 397f122..9ebed07 100644 --- a/Assets/IsoTools/Docs/CHANGELOG.md +++ b/Assets/IsoTools/Docs/CHANGELOG.md @@ -1,3 +1,7 @@ +###### Version 3.1.0 + +* Fix Unity 5.6 warning + ###### Version 3.0.2 * Physics settings in IsoWorld inspector diff --git a/Assets/IsoTools/Scripts/Internal/Editor/IsoEditorUtils.cs b/Assets/IsoTools/Scripts/Internal/Editor/IsoEditorUtils.cs index d53237b..4d8c0d5 100644 --- a/Assets/IsoTools/Scripts/Internal/Editor/IsoEditorUtils.cs +++ b/Assets/IsoTools/Scripts/Internal/Editor/IsoEditorUtils.cs @@ -249,29 +249,9 @@ namespace IsoTools.Internal { // --------------------------------------------------------------------- public static Vector3 GizmoRectangle(Vector3 center) { - Handles.color = new Color( - Handles.zAxisColor.r, - Handles.zAxisColor.g, - Handles.zAxisColor.b, - 0.3f); - Handles.DotCap( - 0, - center, - Quaternion.identity, - HandleUtility.GetHandleSize(center) * 0.15f); - Handles.color = Handles.zAxisColor; - Handles.ArrowCap( - 0, - center, - Quaternion.identity, - HandleUtility.GetHandleSize(center)); - Handles.color = Handles.zAxisColor; - return Handles.FreeMoveHandle( - center, - Quaternion.identity, - HandleUtility.GetHandleSize(center) * 0.15f, - Vector3.zero, - Handles.RectangleCap); + GizmoDotCap(new Color(1.0f, 1.0f, 1.0f, 0.3f) * Handles.zAxisColor, center, 0.15f); + GizmoArrowCap(Handles.zAxisColor, center, 1.0f); + return GizmoFreeMoveHandle(Handles.zAxisColor, center, 0.15f); } public static Vector3 GizmoSlider(Color color, Vector3 pos, Vector3 dir) { @@ -279,6 +259,60 @@ namespace IsoTools.Internal { return Handles.Slider(pos, dir); } + public static void GizmoDotCap(Color color, Vector3 center, float scale) { + Handles.color = color; + #if UNITY_5_6_OR_NEWER + Handles.DotHandleCap( + 0, + center, + Quaternion.identity, + HandleUtility.GetHandleSize(center) * scale, + EventType.Repaint); + #else + Handles.DotCap( + 0, + center, + Quaternion.identity, + HandleUtility.GetHandleSize(center) * scale); + #endif + } + + public static void GizmoArrowCap(Color color, Vector3 center, float scale) { + Handles.color = color; + #if UNITY_5_6_OR_NEWER + Handles.ArrowHandleCap( + 0, + center, + Quaternion.identity, + HandleUtility.GetHandleSize(center) * scale, + EventType.Repaint); + #else + Handles.ArrowCap( + 0, + center, + Quaternion.identity, + HandleUtility.GetHandleSize(center) * scale); + #endif + } + + public static Vector3 GizmoFreeMoveHandle(Color color, Vector3 center, float scale) { + #if UNITY_5_6_OR_NEWER + return Handles.FreeMoveHandle( + center, + Quaternion.identity, + HandleUtility.GetHandleSize(center) * scale, + Vector3.zero, + Handles.RectangleHandleCap); + #else + return Handles.FreeMoveHandle( + center, + Quaternion.identity, + HandleUtility.GetHandleSize(center) * scale, + Vector3.zero, + Handles.RectangleCap); + #endif + } + // --------------------------------------------------------------------- // // Snapping