Example #1
0
            public static void HandlePreferencesGUI()
            {
                if (!preferencesLoaded)
                {
                    Load();
                }

                EditorGUI.BeginChangeCheck();
                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
                    HierarchyHandler.IconsOnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode);
#else
                    HierarchyHandler.IconsOnPlaymodeStateChanged();
#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."));

                EditorGUILayout.Separator();
                EditorGUILayout.LabelField("Auto-Import Settings", EditorStyles.boldLabel);
                {
                    SpineEditorUtilities.FloatPrefsField(ref defaultMix, DEFAULT_MIX_KEY, new GUIContent("Default Mix", "The Default Mix Duration for newly imported SkeletonDataAssets."), min: 0);
                    SpineEditorUtilities.FloatPrefsField(ref defaultScale, DEFAULT_SCALE_KEY, new GUIContent("Default SkeletonData Scale", "The Default skeleton import scale for newly imported SkeletonDataAssets."), min: 0.0000001f);

                    EditorGUI.BeginChangeCheck();
                    var shader = (EditorGUILayout.ObjectField("Default Shader", Shader.Find(defaultShader), typeof(Shader), false) as Shader);
                    defaultShader = shader != null ? shader.name : SpinePreferences.DEFAULT_DEFAULT_SHADER;
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorPrefs.SetString(DEFAULT_SHADER_KEY, defaultShader);
                    }

                    SpineEditorUtilities.BoolPrefsField(ref setTextureImporterSettings, SET_TEXTUREIMPORTER_SETTINGS_KEY, new GUIContent("Apply Atlas Texture Settings", "Apply the recommended settings for Texture Importers."));
                    SpineEditorUtilities.Texture2DPrefsField(ref textureSettingsReference, TEXTURE_SETTINGS_REFERENCE_KEY, new GUIContent("Atlas Texture Reference Settings", "Apply the selected reference texture import settings at newly imported atlas textures. When exporting atlas textures from Spine with \"Premultiply alpha\" enabled (the default), you can leave it at \"PMAPresetTemplate\". If you have disabled \"Premultiply alpha\", set it to \"StraightAlphaPresetTemplate\". You can also create your own reference texture asset and assign it here."));
                    if (string.IsNullOrEmpty(textureSettingsReference))
                    {
                        var pmaTextureSettingsReferenceGUIDS = AssetDatabase.FindAssets("PMAPresetTemplate");
                        if (pmaTextureSettingsReferenceGUIDS.Length > 0)
                        {
                            textureSettingsReference = AssetDatabase.GUIDToAssetPath(pmaTextureSettingsReferenceGUIDS[0]);
                            EditorPrefs.SetString(TEXTURE_SETTINGS_REFERENCE_KEY, textureSettingsReference);
                        }
                    }

                    SpineEditorUtilities.MaterialPrefsField(ref blendModeMaterialAdditive, BLEND_MODE_MATERIAL_ADDITIVE_KEY, new GUIContent("Additive Material", "Additive blend mode Material template."));
                    if (string.IsNullOrEmpty(blendModeMaterialAdditive))
                    {
                        var blendModeMaterialAdditiveGUIDS = AssetDatabase.FindAssets(DEFAULT_BLEND_MODE_ADDITIVE_MATERIAL);
                        if (blendModeMaterialAdditiveGUIDS.Length > 0)
                        {
                            blendModeMaterialAdditive = AssetDatabase.GUIDToAssetPath(blendModeMaterialAdditiveGUIDS[0]);
                        }
                    }
                    SpineEditorUtilities.MaterialPrefsField(ref blendModeMaterialMultiply, BLEND_MODE_MATERIAL_MULTIPLY_KEY, new GUIContent("Multiply Material", "Multiply blend mode Material template."));
                    if (string.IsNullOrEmpty(blendModeMaterialMultiply))
                    {
                        var blendModeMaterialMultiplyGUIDS = AssetDatabase.FindAssets(DEFAULT_BLEND_MODE_MULTIPLY_MATERIAL);
                        if (blendModeMaterialMultiplyGUIDS.Length > 0)
                        {
                            blendModeMaterialMultiply = AssetDatabase.GUIDToAssetPath(blendModeMaterialMultiplyGUIDS[0]);
                        }
                    }
                    SpineEditorUtilities.MaterialPrefsField(ref blendModeMaterialScreen, BLEND_MODE_MATERIAL_SCREEN_KEY, new GUIContent("Screen Material", "Screen blend mode Material template."));
                    if (string.IsNullOrEmpty(blendModeMaterialScreen))
                    {
                        var blendModeMaterialScreenGUIDS = AssetDatabase.FindAssets(DEFAULT_BLEND_MODE_SCREEN_MATERIAL);
                        if (blendModeMaterialScreenGUIDS.Length > 0)
                        {
                            blendModeMaterialScreen = AssetDatabase.GUIDToAssetPath(blendModeMaterialScreenGUIDS[0]);
                        }
                    }
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Warnings", EditorStyles.boldLabel);
                {
                    SpineEditorUtilities.BoolPrefsField(ref atlasTxtImportWarning, ATLASTXT_WARNING_KEY, new GUIContent("Atlas Extension Warning", "Log a warning and recommendation whenever a `.atlas` file is found."));
                    SpineEditorUtilities.BoolPrefsField(ref textureImporterWarning, TEXTUREIMPORTER_WARNING_KEY, new GUIContent("Texture Settings Warning", "Log a warning and recommendation whenever Texture Import Settings are detected that could lead to undesired effects, e.g. white border artifacts."));
                    SpineEditorUtilities.BoolPrefsField(ref componentMaterialWarning, COMPONENTMATERIAL_WARNING_KEY, new GUIContent("Component & Material Warning", "Log a warning and recommendation whenever Component and Material settings are not compatible."));
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Editor Instantiation", EditorStyles.boldLabel);
                {
                    EditorGUI.BeginChangeCheck();
                    defaultZSpacing = EditorGUILayout.Slider("Default Slot Z-Spacing", defaultZSpacing, -0.1f, 0f);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorPrefs.SetFloat(DEFAULT_ZSPACING_KEY, defaultZSpacing);
                    }

                    SpineEditorUtilities.BoolPrefsField(ref defaultInstantiateLoop, DEFAULT_INSTANTIATE_LOOP_KEY, new GUIContent("Default Loop", "Spawn Spine GameObjects with loop enabled."));
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Mecanim Bake Settings", EditorStyles.boldLabel);
                {
                    SpineEditorUtilities.BoolPrefsField(ref mecanimEventIncludeFolderName, MECANIM_EVENT_INCLUDE_FOLDERNAME_KEY, new GUIContent("Include Folder Name in Event", "When enabled, Mecanim events will call methods named 'FolderNameEventName', when disabled it will call 'EventName'."));
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Handles and Gizmos", EditorStyles.boldLabel);
                {
                    EditorGUI.BeginChangeCheck();
                    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, handleScale);
                        SceneView.RepaintAll();
                    }
                }

#if SPINE_TK2D_DEFINE
                bool isTK2DDefineSet = true;
#else
                bool isTK2DDefineSet = false;
#endif
                bool isTK2DAllowed = SpineTK2DEditorUtility.IsTK2DAllowed;
                if (SpineTK2DEditorUtility.IsTK2DInstalled() || isTK2DDefineSet)
                {
                    GUILayout.Space(20);
                    EditorGUILayout.LabelField("3rd Party Settings", EditorStyles.boldLabel);
                    using (new GUILayout.HorizontalScope()) {
                        EditorGUILayout.PrefixLabel("Define TK2D");
                        if (isTK2DAllowed && GUILayout.Button("Enable", GUILayout.Width(64)))
                        {
                            SpineTK2DEditorUtility.EnableTK2D();
                        }
                        if (GUILayout.Button("Disable", GUILayout.Width(64)))
                        {
                            SpineTK2DEditorUtility.DisableTK2D();
                        }
                    }
#if !SPINE_TK2D_DEFINE
                    if (!isTK2DAllowed)
                    {
                        EditorGUILayout.LabelField("To allow TK2D support, please modify line 67 in", EditorStyles.boldLabel);
                        EditorGUILayout.LabelField("Spine/Editor/spine-unity/Editor/Util./BuildSettings.cs", EditorStyles.boldLabel);
                    }
#endif
                }

                GUILayout.Space(20);
                EditorGUILayout.LabelField("Timeline Extension", EditorStyles.boldLabel);
                {
                    SpineEditorUtilities.BoolPrefsField(ref timelineUseBlendDuration, TIMELINE_USE_BLEND_DURATION_KEY, new GUIContent("Use Blend Duration", "When enabled, MixDuration will be synced with timeline clip transition duration 'Ease In Duration'."));
                }
            }
            public static void HandlePreferencesGUI()
            {
                if (!preferencesLoaded)
                {
                    Load();
                }

                EditorGUI.BeginChangeCheck();
                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
                    HierarchyHandler.IconsOnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode);
                                #else
                    HierarchyHandler.IconsOnPlaymodeStateChanged();
                                #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."));

                EditorGUILayout.Separator();
                EditorGUILayout.LabelField("Auto-Import Settings", EditorStyles.boldLabel);
                {
                    SpineEditorUtilities.FloatPrefsField(ref defaultMix, DEFAULT_MIX_KEY, new GUIContent("Default Mix", "The Default Mix Duration for newly imported SkeletonDataAssets."), min: 0);
                    SpineEditorUtilities.FloatPrefsField(ref defaultScale, DEFAULT_SCALE_KEY, new GUIContent("Default SkeletonData Scale", "The Default skeleton import scale for newly imported SkeletonDataAssets."), min: 0.0000001f);

                    EditorGUI.BeginChangeCheck();
                    var shader = (EditorGUILayout.ObjectField("Default Shader", Shader.Find(defaultShader), typeof(Shader), false) as Shader);
                    defaultShader = shader != null ? shader.name : SpinePreferences.DEFAULT_DEFAULT_SHADER;
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorPrefs.SetString(DEFAULT_SHADER_KEY, defaultShader);
                    }

                    SpineEditorUtilities.BoolPrefsField(ref setTextureImporterSettings, SET_TEXTUREIMPORTER_SETTINGS_KEY, new GUIContent("Apply Atlas Texture Settings", "Apply the recommended settings for Texture Importers."));
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Warnings", EditorStyles.boldLabel);
                {
                    SpineEditorUtilities.BoolPrefsField(ref atlasTxtImportWarning, ATLASTXT_WARNING_KEY, new GUIContent("Atlas Extension Warning", "Log a warning and recommendation whenever a `.atlas` file is found."));
                    SpineEditorUtilities.BoolPrefsField(ref textureImporterWarning, TEXTUREIMPORTER_WARNING_KEY, new GUIContent("Texture Settings Warning", "Log a warning and recommendation whenever Texture Import Settings are detected that could lead to undesired effects, e.g. white border artifacts."));
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Editor Instantiation", EditorStyles.boldLabel);
                {
                    EditorGUI.BeginChangeCheck();
                    defaultZSpacing = EditorGUILayout.Slider("Default Slot Z-Spacing", defaultZSpacing, -0.1f, 0f);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorPrefs.SetFloat(DEFAULT_ZSPACING_KEY, defaultZSpacing);
                    }

                    SpineEditorUtilities.BoolPrefsField(ref defaultInstantiateLoop, DEFAULT_INSTANTIATE_LOOP_KEY, new GUIContent("Default Loop", "Spawn Spine GameObjects with loop enabled."));
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Mecanim Bake Settings", EditorStyles.boldLabel);
                {
                    SpineEditorUtilities.BoolPrefsField(ref mecanimEventIncludeFolderName, MECANIM_EVENT_INCLUDE_FOLDERNAME_KEY, new GUIContent("Include Folder Name in Event", "When enabled, Mecanim events will call methods named 'FolderNameEventName', when disabled it will call 'EventName'."));
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Handles and Gizmos", EditorStyles.boldLabel);
                {
                    EditorGUI.BeginChangeCheck();
                    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, handleScale);
                        SceneView.RepaintAll();
                    }
                }

                GUILayout.Space(20);
                EditorGUILayout.LabelField("3rd Party Settings", EditorStyles.boldLabel);
                using (new GUILayout.HorizontalScope()) {
                    EditorGUILayout.PrefixLabel("Define TK2D");
                    if (GUILayout.Button("Enable", GUILayout.Width(64)))
                    {
                        SpineTK2DEditorUtility.EnableTK2D();
                    }
                    if (GUILayout.Button("Disable", GUILayout.Width(64)))
                    {
                        SpineTK2DEditorUtility.DisableTK2D();
                    }
                }

                GUILayout.Space(20);
                EditorGUILayout.LabelField("Timeline Extension", EditorStyles.boldLabel);
                {
                    SpineEditorUtilities.BoolPrefsField(ref timelineUseBlendDuration, TIMELINE_USE_BLEND_DURATION_KEY, new GUIContent("Use Blend Duration", "When enabled, MixDuration will be synced with timeline clip transition duration 'Ease In Duration'."));
                }
            }