diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Preferences.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Preferences.cs index 16d6257ba..d8f90e195 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Preferences.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Preferences.cs @@ -129,8 +129,8 @@ namespace Spine.Unity.Editor { public const float DEFAULT_MIPMAPBIAS = SpinePreferences.DEFAULT_MIPMAPBIAS; - public const float DEFAULT_SCENE_ICONS_SCALE = SpinePreferences.DEFAULT_SCENE_ICONS_SCALE; - public const string SCENE_ICONS_SCALE_KEY = SpinePreferences.SCENE_ICONS_SCALE_KEY; + public const string SCENE_ICONS_SCALE_KEY = "SPINE_SCENE_ICONS_SCALE"; + public static float handleScale = SpinePreferences.DEFAULT_SCENE_ICONS_SCALE; const string AUTO_RELOAD_SCENESKELETONS_KEY = "SPINE_AUTO_RELOAD_SCENESKELETONS"; public static bool autoReloadSceneSkeletons = SpinePreferences.DEFAULT_AUTO_RELOAD_SCENESKELETONS; @@ -141,6 +141,7 @@ namespace Spine.Unity.Editor { const string TIMELINE_USE_BLEND_DURATION_KEY = "SPINE_TIMELINE_USE_BLEND_DURATION_KEY"; public static bool timelineUseBlendDuration = SpinePreferences.DEFAULT_TIMELINE_USE_BLEND_DURATION; + static bool preferencesLoaded = false; public static void Load () { @@ -158,8 +159,7 @@ namespace Spine.Unity.Editor { atlasTxtImportWarning = EditorPrefs.GetBool(ATLASTXT_WARNING_KEY, SpinePreferences.DEFAULT_ATLASTXT_WARNING); textureImporterWarning = EditorPrefs.GetBool(TEXTUREIMPORTER_WARNING_KEY, SpinePreferences.DEFAULT_TEXTUREIMPORTER_WARNING); timelineUseBlendDuration = EditorPrefs.GetBool(TIMELINE_USE_BLEND_DURATION_KEY, SpinePreferences.DEFAULT_TIMELINE_USE_BLEND_DURATION); - - SpineHandles.handleScale = EditorPrefs.GetFloat(SCENE_ICONS_SCALE_KEY, DEFAULT_SCENE_ICONS_SCALE); + handleScale = EditorPrefs.GetFloat(SCENE_ICONS_SCALE_KEY, SpinePreferences.DEFAULT_SCENE_ICONS_SCALE); preferencesLoaded = true; } @@ -176,6 +176,7 @@ namespace Spine.Unity.Editor { newPreferences.atlasTxtImportWarning = EditorPrefs.GetBool(ATLASTXT_WARNING_KEY, SpinePreferences.DEFAULT_ATLASTXT_WARNING); newPreferences.textureImporterWarning = EditorPrefs.GetBool(TEXTUREIMPORTER_WARNING_KEY, SpinePreferences.DEFAULT_TEXTUREIMPORTER_WARNING); newPreferences.timelineUseBlendDuration = EditorPrefs.GetBool(TIMELINE_USE_BLEND_DURATION_KEY, SpinePreferences.DEFAULT_TIMELINE_USE_BLEND_DURATION); + newPreferences.handleScale = EditorPrefs.GetBool(SCENE_ICONS_SCALE_KEY, SpinePreferences.DEFAULT_SCENE_ICONS_SCALE); } public static void SaveToEditorPrefs(SpinePreferences preferences) { @@ -190,6 +191,7 @@ namespace Spine.Unity.Editor { EditorPrefs.SetBool(ATLASTXT_WARNING_KEY, preferences.atlasTxtImportWarning); EditorPrefs.SetBool(TEXTUREIMPORTER_WARNING_KEY, preferences.textureImporterWarning); EditorPrefs.SetBool(TIMELINE_USE_BLEND_DURATION_KEY, preferences.timelineUseBlendDuration); + EditorPrefs.SetBool(SCENE_ICONS_SCALE_KEY, preferences.handleScale); } #endif @@ -254,10 +256,10 @@ namespace Spine.Unity.Editor { EditorGUILayout.LabelField("Handles and Gizmos", EditorStyles.boldLabel); { EditorGUI.BeginChangeCheck(); - SpineHandles.handleScale = EditorGUILayout.Slider("Editor Bone Scale", SpineHandles.handleScale, 0.01f, 2f); - SpineHandles.handleScale = Mathf.Max(0.01f, SpineHandles.handleScale); + handleScale = EditorGUILayout.Slider("Editor Bone Scale", handleScale, 0.01f, 2f); + handleScale = Mathf.Max(0.01f, handleScale); if (EditorGUI.EndChangeCheck()) { - EditorPrefs.SetFloat(SCENE_ICONS_SCALE_KEY, SpineHandles.handleScale); + EditorPrefs.SetFloat(SCENE_ICONS_SCALE_KEY, handleScale); SceneView.RepaintAll(); } } diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineHandles.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineHandles.cs index 3fffd53a3..afa5a91ba 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineHandles.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineHandles.cs @@ -44,7 +44,6 @@ namespace Spine.Unity.Editor { using EventType = UnityEngine.EventType; public static class SpineHandles { - internal static float handleScale = 1f; public static Color BoneColor { get { return new Color(0.8f, 0.8f, 0.8f, 0.4f); } } public static Color PathColor { get { return new Color(254/255f, 127/255f, 0); } } public static Color TransformContraintColor { get { return new Color(170/255f, 226/255f, 35/255f); } } @@ -200,7 +199,7 @@ namespace Spine.Unity.Editor { Quaternion rot = Quaternion.Euler(0, 0, b.WorldRotationX); Vector3 scale = Vector3.one * length * b.WorldScaleX * skeletonRenderScale; const float my = 1.5f; - scale.y *= (SpineHandles.handleScale + 1) * 0.5f; + scale.y *= (SpineEditorUtilities.Preferences.handleScale + 1) * 0.5f; scale.y = Mathf.Clamp(scale.x, -my * skeletonRenderScale, my * skeletonRenderScale); Handles.DrawPolyLine(GetBoneWireBuffer(transform.localToWorldMatrix * Matrix4x4.TRS(pos, rot, scale))); var wp = transform.TransformPoint(pos); @@ -218,7 +217,7 @@ namespace Spine.Unity.Editor { Quaternion rot = Quaternion.Euler(0, 0, b.WorldRotationX); Vector3 scale = Vector3.one * length * b.WorldScaleX * skeletonRenderScale; const float my = 1.5f; - scale.y *= (SpineHandles.handleScale + 1f) * 0.5f; + scale.y *= (SpineEditorUtilities.Preferences.handleScale + 1f) * 0.5f; scale.y = Mathf.Clamp(scale.x, -my * skeletonRenderScale, my * skeletonRenderScale); SpineHandles.GetBoneMaterial().SetPass(0); Graphics.DrawMeshNow(SpineHandles.BoneMesh, transform.localToWorldMatrix * Matrix4x4.TRS(pos, rot, scale)); @@ -235,7 +234,7 @@ namespace Spine.Unity.Editor { Quaternion rot = Quaternion.Euler(0, 0, b.WorldRotationX); Vector3 scale = Vector3.one * length * b.WorldScaleX; const float my = 1.5f; - scale.y *= (SpineHandles.handleScale + 1f) * 0.5f; + scale.y *= (SpineEditorUtilities.Preferences.handleScale + 1f) * 0.5f; scale.y = Mathf.Clamp(scale.x, -my, my); SpineHandles.GetBoneMaterial(color).SetPass(0); Graphics.DrawMeshNow(SpineHandles.BoneMesh, transform.localToWorldMatrix * Matrix4x4.TRS(pos, rot, scale)); @@ -425,13 +424,13 @@ namespace Spine.Unity.Editor { } static void DrawCrosshairs2D (Vector3 position, float scale, float skeletonRenderScale = 1f) { - scale *= SpineHandles.handleScale * skeletonRenderScale; + scale *= SpineEditorUtilities.Preferences.handleScale * skeletonRenderScale; Handles.DrawLine(position + new Vector3(-scale, 0), position + new Vector3(scale, 0)); Handles.DrawLine(position + new Vector3(0, -scale), position + new Vector3(0, scale)); } static void DrawCrosshairs (Vector3 position, float scale, float a, float b, float c, float d, Transform transform, float skeletonRenderScale = 1f) { - scale *= SpineHandles.handleScale * skeletonRenderScale; + scale *= SpineEditorUtilities.Preferences.handleScale * skeletonRenderScale; var xOffset = (Vector3)(new Vector2(a, c).normalized * scale); var yOffset = (Vector3)(new Vector2(b, d).normalized * scale); @@ -443,7 +442,7 @@ namespace Spine.Unity.Editor { } static void DrawArrowhead2D (Vector3 pos, float localRotation, float scale = 1f) { - scale *= SpineHandles.handleScale; + scale *= SpineEditorUtilities.Preferences.handleScale; SpineHandles.IKMaterial.SetPass(0); Graphics.DrawMeshNow(SpineHandles.ArrowheadMesh, Matrix4x4.TRS(pos, Quaternion.Euler(0, 0, localRotation), new Vector3(scale, scale, scale))); @@ -454,7 +453,7 @@ namespace Spine.Unity.Editor { } static void DrawArrowhead (Matrix4x4 m) { - float s = SpineHandles.handleScale; + float s = SpineEditorUtilities.Preferences.handleScale; m.m00 *= s; m.m01 *= s; m.m02 *= s; @@ -470,14 +469,14 @@ namespace Spine.Unity.Editor { } static void DrawBoneCircle (Vector3 pos, Color outlineColor, Vector3 normal, float scale = 1f) { - scale *= SpineHandles.handleScale; + scale *= SpineEditorUtilities.Preferences.handleScale; Color o = Handles.color; Handles.color = outlineColor; float firstScale = 0.08f * scale; Handles.DrawSolidDisc(pos, normal, firstScale); const float Thickness = 0.03f; - float secondScale = firstScale - (Thickness * SpineHandles.handleScale * scale); + float secondScale = firstScale - (Thickness * SpineEditorUtilities.Preferences.handleScale * scale); if (secondScale > 0f) { Handles.color = new Color(0.3f, 0.3f, 0.3f, 0.5f); diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpinePreferences.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpinePreferences.cs index 4343311b9..32acff2a5 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpinePreferences.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpinePreferences.cs @@ -87,7 +87,7 @@ namespace Spine.Unity.Editor { public bool autoReloadSceneSkeletons = DEFAULT_AUTO_RELOAD_SCENESKELETONS; internal const float DEFAULT_SCENE_ICONS_SCALE = 1f; - public const string SCENE_ICONS_SCALE_KEY = "SPINE_SCENE_ICONS_SCALE"; + public static float handleScale = DEFAULT_SCENE_ICONS_SCALE; public const bool DEFAULT_MECANIM_EVENT_INCLUDE_FOLDERNAME = true; public bool mecanimEventIncludeFolderName = DEFAULT_MECANIM_EVENT_INCLUDE_FOLDERNAME; @@ -98,7 +98,6 @@ namespace Spine.Unity.Editor { #if NEW_PREFERENCES_SETTINGS_PROVIDER public static void Load () { - SpineHandles.handleScale = EditorPrefs.GetFloat(SCENE_ICONS_SCALE_KEY, DEFAULT_SCENE_ICONS_SCALE); GetOrCreateSettings(); } @@ -172,10 +171,10 @@ namespace Spine.Unity.Editor { EditorGUILayout.LabelField("Handles and Gizmos", EditorStyles.boldLabel); { EditorGUI.BeginChangeCheck(); - SpineHandles.handleScale = EditorGUILayout.Slider("Editor Bone Scale", SpineHandles.handleScale, 0.01f, 2f); - SpineHandles.handleScale = Mathf.Max(0.01f, SpineHandles.handleScale); + handleScale = EditorGUILayout.Slider("Editor Bone Scale", handleScale, 0.01f, 2f); + handleScale = Mathf.Max(0.01f, handleScale); if (EditorGUI.EndChangeCheck()) { - EditorPrefs.SetFloat(SpinePreferences.SCENE_ICONS_SCALE_KEY, SpineHandles.handleScale); + EditorPrefs.SetFloat(SpinePreferences.SCENE_ICONS_SCALE_KEY, handleScale); SceneView.RepaintAll(); } }