Exemplo n.º 1
0
        public static void HandlePreferencesGUI(SerializedObject settings)
        {
            float prevLabelWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 250;

            using (new EditorGUI.IndentLevelScope()) {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(settings.FindProperty("showHierarchyIcons"), new GUIContent("Show Hierarchy Icons", "Show relevant icons on GameObjects with Spine Components on them. Disable this if you have large, complex scenes."));
                if (EditorGUI.EndChangeCheck())
                {
                                        #if NEWPLAYMODECALLBACKS
                    SpineEditorUtilities.HierarchyHandler.IconsOnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode);
                                        #else
                    SpineEditorUtilities.HierarchyHandler.IconsOnPlaymodeStateChanged();
                                        #endif
                }

                EditorGUILayout.PropertyField(settings.FindProperty("autoReloadSceneSkeletons"), 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.FloatPropertyField(settings.FindProperty("defaultMix"), new GUIContent("Default Mix", "The Default Mix Duration for newly imported SkeletonDataAssets."), min: 0f);
                    SpineEditorUtilities.FloatPropertyField(settings.FindProperty("defaultScale"), new GUIContent("Default SkeletonData Scale", "The Default skeleton import scale for newly imported SkeletonDataAssets."), min: 0.0000001f);

                    SpineEditorUtilities.ShaderPropertyField(settings.FindProperty("defaultShader"), new GUIContent("Default Shader"), SpinePreferences.DEFAULT_DEFAULT_SHADER);

                    EditorGUILayout.PropertyField(settings.FindProperty("setTextureImporterSettings"), new GUIContent("Apply Atlas Texture Settings", "Apply the recommended settings for Texture Importers."));
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Warnings", EditorStyles.boldLabel);
                {
                    EditorGUILayout.PropertyField(settings.FindProperty("atlasTxtImportWarning"), new GUIContent("Atlas Extension Warning", "Log a warning and recommendation whenever a `.atlas` file is found."));
                    EditorGUILayout.PropertyField(settings.FindProperty("textureImporterWarning"), 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);
                {
                    EditorGUILayout.Slider(settings.FindProperty("defaultZSpacing"), -0.1f, 0f, new GUIContent("Default Slot Z-Spacing"));
                    EditorGUILayout.PropertyField(settings.FindProperty("defaultInstantiateLoop"), new GUIContent("Default Loop", "Spawn Spine GameObjects with loop enabled."));
                }

                EditorGUILayout.Space();
                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);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorPrefs.SetFloat(SpinePreferences.SCENE_ICONS_SCALE_KEY, SpineHandles.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)))
                    {
                        SpineEditorUtilities.SpineTK2DEditorUtility.EnableTK2D();
                    }
                    if (GUILayout.Button("Disable", GUILayout.Width(64)))
                    {
                        SpineEditorUtilities.SpineTK2DEditorUtility.DisableTK2D();
                    }
                }
            }
            EditorGUIUtility.labelWidth = prevLabelWidth;
        }
Exemplo n.º 2
0
        public static void HandlePreferencesGUI(SerializedObject settings)
        {
            float prevLabelWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 250;

            using (new EditorGUI.IndentLevelScope()) {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(settings.FindProperty("showHierarchyIcons"), new GUIContent("Show Hierarchy Icons", "Show relevant icons on GameObjects with Spine Components on them. Disable this if you have large, complex scenes."));
                if (EditorGUI.EndChangeCheck())
                {
#if NEWPLAYMODECALLBACKS
                    SpineEditorUtilities.HierarchyHandler.IconsOnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode);
#else
                    SpineEditorUtilities.HierarchyHandler.IconsOnPlaymodeStateChanged();
#endif
                }

                EditorGUILayout.PropertyField(settings.FindProperty("autoReloadSceneSkeletons"), 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.FloatPropertyField(settings.FindProperty("defaultMix"), new GUIContent("Default Mix", "The Default Mix Duration for newly imported SkeletonDataAssets."), min: 0f);
                    SpineEditorUtilities.FloatPropertyField(settings.FindProperty("defaultScale"), new GUIContent("Default SkeletonData Scale", "The Default skeleton import scale for newly imported SkeletonDataAssets."), min: 0.0000001f);

                    SpineEditorUtilities.ShaderPropertyField(settings.FindProperty("defaultShader"), new GUIContent("Default Shader"), SpinePreferences.DEFAULT_DEFAULT_SHADER);

                    EditorGUILayout.PropertyField(settings.FindProperty("setTextureImporterSettings"), new GUIContent("Apply Atlas Texture Settings", "Apply reference settings for Texture Importers."));
                    var textureSettingsRef = settings.FindProperty("textureSettingsReference");
                    SpineEditorUtilities.PresetAssetPropertyField(textureSettingsRef, new GUIContent("Atlas Texture Settings", "Apply the selected 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 \"PMATexturePreset\". If you have disabled \"Premultiply alpha\", set it to \"StraightAlphaTexturePreset\". You can also create your own TextureImporter Preset asset and assign it here."));
                    if (string.IsNullOrEmpty(textureSettingsRef.stringValue))
                    {
                        var pmaTextureSettingsReferenceGUIDS = AssetDatabase.FindAssets("PMATexturePreset");
                        if (pmaTextureSettingsReferenceGUIDS.Length > 0)
                        {
                            textureSettingsRef.stringValue = AssetDatabase.GUIDToAssetPath(pmaTextureSettingsReferenceGUIDS[0]);
                        }
                    }
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Warnings", EditorStyles.boldLabel);
                {
                    EditorGUILayout.PropertyField(settings.FindProperty("atlasTxtImportWarning"), new GUIContent("Atlas Extension Warning", "Log a warning and recommendation whenever a `.atlas` file is found."));
                    EditorGUILayout.PropertyField(settings.FindProperty("textureImporterWarning"), 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.PropertyField(settings.FindProperty("componentMaterialWarning"), 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);
                {
                    EditorGUILayout.Slider(settings.FindProperty("defaultZSpacing"), -0.1f, 0f, new GUIContent("Default Slot Z-Spacing"));
                    EditorGUILayout.PropertyField(settings.FindProperty("defaultInstantiateLoop"), new GUIContent("Default Loop", "Spawn Spine GameObjects with loop enabled."));
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Mecanim Bake Settings", EditorStyles.boldLabel);
                {
                    EditorGUILayout.PropertyField(settings.FindProperty("mecanimEventIncludeFolderName"), 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();
                    var scaleProperty = settings.FindProperty("handleScale");
                    EditorGUILayout.PropertyField(scaleProperty, new GUIContent("Editor Bone Scale"));
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorPrefs.SetFloat(SpinePreferences.SCENE_ICONS_SCALE_KEY, scaleProperty.floatValue);
                        SceneView.RepaintAll();
                    }
                }

                                #if SPINE_TK2D_DEFINE
                bool isTK2DDefineSet = true;
                                #else
                bool isTK2DDefineSet = false;
                                #endif
                bool isTK2DAllowed = SpineEditorUtilities.SpineTK2DEditorUtility.IsTK2DAllowed;
                if (SpineEditorUtilities.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)))
                        {
                            SpineEditorUtilities.SpineTK2DEditorUtility.EnableTK2D();
                        }
                        if (GUILayout.Button("Disable", GUILayout.Width(64)))
                        {
                            SpineEditorUtilities.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);
                {
                    EditorGUILayout.PropertyField(settings.FindProperty("timelineUseBlendDuration"), new GUIContent("Use Blend Duration", "When enabled, MixDuration will be synced with timeline clip transition duration 'Ease In Duration'."));
                }
            }
            EditorGUIUtility.labelWidth = prevLabelWidth;
        }