internal static SpinePreferences GetOrCreateSettings()
        {
            if (settings != null)
            {
                return(settings);
            }

            settings = AssetDatabase.LoadAssetAtPath <SpinePreferences>(SPINE_SETTINGS_ASSET_PATH);
            if (settings == null)
            {
                settings = FindSpinePreferences();
            }
            if (settings == null)
            {
                settings = ScriptableObject.CreateInstance <SpinePreferences>();
                SpineEditorUtilities.OldPreferences.CopyOldToNewPreferences(ref settings);
                // Multiple threads may be calling this method during import, creating the folder
                // multiple times with ascending number suffix. Atomic wasPreferencesDirCreated int
                // variable is used to prevent any redundant create operations.
                if (!AssetDatabase.IsValidFolder("Assets/Editor") && Interlocked.Exchange(ref wasPreferencesDirCreated, 1) == 0)
                {
                    AssetDatabase.CreateFolder("Assets", "Editor");
                }
                if (Interlocked.Exchange(ref wasPreferencesAssetCreated, 1) == 0)
                {
                    AssetDatabase.CreateAsset(settings, SPINE_SETTINGS_ASSET_PATH);
                }
            }
            return(settings);
        }
Example #2
0
 public static void SaveToEditorPrefs(SpinePreferences preferences)
 {
     EditorPrefs.SetFloat(DEFAULT_MIX_KEY, preferences.defaultMix);
     EditorPrefs.SetFloat(DEFAULT_SCALE_KEY, preferences.defaultScale);
     EditorPrefs.SetFloat(DEFAULT_ZSPACING_KEY, preferences.defaultZSpacing);
     EditorPrefs.SetString(DEFAULT_SHADER_KEY, preferences.defaultShader);
     EditorPrefs.SetBool(SHOW_HIERARCHY_ICONS_KEY, preferences.showHierarchyIcons);
     EditorPrefs.SetBool(SET_TEXTUREIMPORTER_SETTINGS_KEY, preferences.setTextureImporterSettings);
     EditorPrefs.SetBool(AUTO_RELOAD_SCENESKELETONS_KEY, preferences.autoReloadSceneSkeletons);
     EditorPrefs.SetBool(ATLASTXT_WARNING_KEY, preferences.atlasTxtImportWarning);
     EditorPrefs.SetBool(TEXTUREIMPORTER_WARNING_KEY, preferences.textureImporterWarning);
 }
Example #3
0
 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);
 }
Example #4
0
 public static void SaveToEditorPrefs(SpinePreferences preferences)
 {
     EditorPrefs.SetFloat(DEFAULT_MIX_KEY, preferences.defaultMix);
     EditorPrefs.SetFloat(DEFAULT_SCALE_KEY, preferences.defaultScale);
     EditorPrefs.SetFloat(DEFAULT_ZSPACING_KEY, preferences.defaultZSpacing);
     EditorPrefs.SetString(DEFAULT_SHADER_KEY, preferences.defaultShader);
     EditorPrefs.SetBool(SHOW_HIERARCHY_ICONS_KEY, preferences.showHierarchyIcons);
     EditorPrefs.SetBool(SET_TEXTUREIMPORTER_SETTINGS_KEY, preferences.setTextureImporterSettings);
     EditorPrefs.SetBool(AUTO_RELOAD_SCENESKELETONS_KEY, preferences.autoReloadSceneSkeletons);
     EditorPrefs.SetBool(MECANIM_EVENT_INCLUDE_FOLDERNAME_KEY, preferences.mecanimEventIncludeFolderName);
     EditorPrefs.SetBool(ATLASTXT_WARNING_KEY, preferences.atlasTxtImportWarning);
     EditorPrefs.SetBool(TEXTUREIMPORTER_WARNING_KEY, preferences.textureImporterWarning);
     EditorPrefs.SetBool(TIMELINE_USE_BLEND_DURATION_KEY, preferences.timelineUseBlendDuration);
 }
Example #5
0
 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.mecanimEventIncludeFolderName = EditorPrefs.GetBool(MECANIM_EVENT_INCLUDE_FOLDERNAME_KEY, SpinePreferences.DEFAULT_MECANIM_EVENT_INCLUDE_FOLDERNAME);
     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);
 }
Example #6
0
            public static SettingsProvider CreateSpineSettingsProvider()
            {
                var provider = new SettingsProvider("Spine", SettingsScope.User)
                {
                    label      = "Spine",
                    guiHandler = (searchContext) =>
                    {
                        var settings           = SpinePreferences.GetOrCreateSettings();
                        var serializedSettings = new SerializedObject(settings);
                        SpinePreferences.HandlePreferencesGUI(serializedSettings);
                        if (serializedSettings.ApplyModifiedProperties())
                        {
                            OldPreferences.SaveToEditorPrefs(settings);
                        }
                    },

                    // Populate the search keywords to enable smart search filtering and label highlighting:
                    keywords = new HashSet <string>(new[] { "Spine", "Preferences", "Skeleton", "Default", "Mix", "Duration" })
                };

                return(provider);
            }
        static void Initialize()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                return;
            }

                        #if !NEW_PREFERENCES_SETTINGS_PROVIDER
            Preferences.Load();
                        #else
            SpinePreferences.Load();
                        #endif

            string[] assets    = AssetDatabase.FindAssets("t:script SpineEditorUtilities");
            string   assetPath = AssetDatabase.GUIDToAssetPath(assets[0]);
            editorPath = Path.GetDirectoryName(assetPath).Replace("\\", "/");

            assets = AssetDatabase.FindAssets("t:texture icon-subMeshRenderer");
            if (assets.Length > 0)
            {
                assetPath     = AssetDatabase.GUIDToAssetPath(assets[0]);
                editorGUIPath = Path.GetDirectoryName(assetPath).Replace("\\", "/");
            }
            else
            {
                editorGUIPath = editorPath.Replace("/Utility", "/GUI");
            }
            Icons.Initialize();

            // Drag and Drop
                #if UNITY_2019_1_OR_NEWER
            SceneView.duringSceneGui -= DragAndDropInstantiation.SceneViewDragAndDrop;
            SceneView.duringSceneGui += DragAndDropInstantiation.SceneViewDragAndDrop;
                #else
            SceneView.onSceneGUIDelegate -= DragAndDropInstantiation.SceneViewDragAndDrop;
            SceneView.onSceneGUIDelegate += DragAndDropInstantiation.SceneViewDragAndDrop;
                #endif

            EditorApplication.hierarchyWindowItemOnGUI -= HierarchyHandler.HandleDragAndDrop;
            EditorApplication.hierarchyWindowItemOnGUI += HierarchyHandler.HandleDragAndDrop;

            // Hierarchy Icons
                        #if NEWPLAYMODECALLBACKS
            EditorApplication.playModeStateChanged -= HierarchyHandler.IconsOnPlaymodeStateChanged;
            EditorApplication.playModeStateChanged += HierarchyHandler.IconsOnPlaymodeStateChanged;
            HierarchyHandler.IconsOnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode);
                        #else
            EditorApplication.playmodeStateChanged -= HierarchyHandler.IconsOnPlaymodeStateChanged;
            EditorApplication.playmodeStateChanged += HierarchyHandler.IconsOnPlaymodeStateChanged;
            HierarchyHandler.IconsOnPlaymodeStateChanged();
                        #endif

            // Data Refresh Edit Mode.
            // This prevents deserialized SkeletonData from persisting from play mode to edit mode.
                        #if NEWPLAYMODECALLBACKS
            EditorApplication.playModeStateChanged -= DataReloadHandler.OnPlaymodeStateChanged;
            EditorApplication.playModeStateChanged += DataReloadHandler.OnPlaymodeStateChanged;
            DataReloadHandler.OnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode);
                        #else
            EditorApplication.playmodeStateChanged -= DataReloadHandler.OnPlaymodeStateChanged;
            EditorApplication.playmodeStateChanged += DataReloadHandler.OnPlaymodeStateChanged;
            DataReloadHandler.OnPlaymodeStateChanged();
                        #endif

            if (SpineEditorUtilities.Preferences.textureImporterWarning)
            {
                IssueWarningsForUnrecommendedTextureSettings();
            }

            initialized = true;
        }