From bb52cce293d32588ab0efd3cc8a1576aa0357b6d Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Fri, 26 Apr 2019 19:21:49 +0200 Subject: [PATCH] [unity] Automatically copying previous Spine - Preferences settings over to SpineSettings.asset at first creation. See 1336. --- .../Editor/SpineEditorUtilities.cs | 24 +++++++++++++++---- .../spine-unity/Editor/SpinePreferences.cs | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineEditorUtilities.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineEditorUtilities.cs index 8d50690fb..43ac0f63f 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineEditorUtilities.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineEditorUtilities.cs @@ -395,7 +395,21 @@ namespace Spine.Unity.Editor { preferencesLoaded = true; } - #if !NEW_PREFERENCES_SETTINGS_PROVIDER + #if NEW_PREFERENCES_SETTINGS_PROVIDER + public static void CopyOldToNewPreferences(ref SpinePreferences newPreferences) { + newPreferences.defaultMix = EditorPrefs.GetFloat(DEFAULT_MIX_KEY, SpinePreferences.DEFAULT_DEFAULT_MIX); + newPreferences.defaultScale = EditorPrefs.GetFloat(DEFAULT_SCALE_KEY, SpinePreferences.DEFAULT_DEFAULT_SCALE); + newPreferences.defaultZSpacing = EditorPrefs.GetFloat(DEFAULT_ZSPACING_KEY, SpinePreferences.DEFAULT_DEFAULT_ZSPACING); + newPreferences.defaultShader = EditorPrefs.GetString(DEFAULT_SHADER_KEY, SpinePreferences.DEFAULT_DEFAULT_SHADER); + newPreferences.showHierarchyIcons = EditorPrefs.GetBool(SHOW_HIERARCHY_ICONS_KEY, SpinePreferences.DEFAULT_SHOW_HIERARCHY_ICONS); + newPreferences.setTextureImporterSettings = EditorPrefs.GetBool(SET_TEXTUREIMPORTER_SETTINGS_KEY, SpinePreferences.DEFAULT_SET_TEXTUREIMPORTER_SETTINGS); + newPreferences.autoReloadSceneSkeletons = EditorPrefs.GetBool(AUTO_RELOAD_SCENESKELETONS_KEY, SpinePreferences.DEFAULT_AUTO_RELOAD_SCENESKELETONS); + newPreferences.atlasTxtImportWarning = EditorPrefs.GetBool(ATLASTXT_WARNING_KEY, SpinePreferences.DEFAULT_ATLASTXT_WARNING); + newPreferences.textureImporterWarning = EditorPrefs.GetBool(TEXTUREIMPORTER_WARNING_KEY, SpinePreferences.DEFAULT_TEXTUREIMPORTER_WARNING); + } + #endif + +#if !NEW_PREFERENCES_SETTINGS_PROVIDER public static void HandlePreferencesGUI () { if (!preferencesLoaded) Load(); @@ -404,11 +418,11 @@ namespace Spine.Unity.Editor { showHierarchyIcons = EditorGUILayout.Toggle(new GUIContent("Show Hierarchy Icons", "Show relevant icons on GameObjects with Spine Components on them. Disable this if you have large, complex scenes."), showHierarchyIcons); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetBool(SHOW_HIERARCHY_ICONS_KEY, showHierarchyIcons); - #if NEWPLAYMODECALLBACKS +#if NEWPLAYMODECALLBACKS HierarchyHandler.IconsOnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode); - #else +#else HierarchyHandler.IconsOnPlaymodeStateChanged(); - #endif +#endif } BoolPrefsField(ref autoReloadSceneSkeletons, AUTO_RELOAD_SCENESKELETONS_KEY, new GUIContent("Auto-reload scene components", "Reloads Skeleton components in the scene whenever their SkeletonDataAsset is modified. This makes it so changes in the SkeletonDataAsset inspector are immediately reflected. This may be slow when your scenes have large numbers of SkeletonRenderers or SkeletonGraphic.")); @@ -470,7 +484,7 @@ namespace Spine.Unity.Editor { SpineTK2DEditorUtility.DisableTK2D(); } } - #endif // !NEW_PREFERENCES_SETTINGS_PROVIDER +#endif // !NEW_PREFERENCES_SETTINGS_PROVIDER } static void BoolPrefsField (ref bool currentValue, string editorPrefsKey, GUIContent label) { diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpinePreferences.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpinePreferences.cs index 1a63a6d82..a022fc0d8 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpinePreferences.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpinePreferences.cs @@ -95,6 +95,7 @@ namespace Spine.Unity.Editor { if (settings == null) { settings = ScriptableObject.CreateInstance(); + SpineEditorUtilities.OldPreferences.CopyOldToNewPreferences(ref settings); if (!AssetDatabase.IsValidFolder("Assets/Editor")) AssetDatabase.CreateFolder("Assets", "Editor"); AssetDatabase.CreateAsset(settings, SPINE_SETTINGS_ASSET_PATH);