|
@@ -121,6 +121,9 @@ namespace Spine.Unity.Editor {
|
|
|
const string SET_TEXTUREIMPORTER_SETTINGS_KEY = "SPINE_SET_TEXTUREIMPORTER_SETTINGS";
|
|
|
public static bool setTextureImporterSettings = SpinePreferences.DEFAULT_SET_TEXTUREIMPORTER_SETTINGS;
|
|
|
|
|
|
+ const string TEXTURE_SETTINGS_REFERENCE_KEY = "SPINE_TEXTURE_SETTINGS_REFERENCE";
|
|
|
+ public static string textureSettingsReference = SpinePreferences.DEFAULT_TEXTURE_SETTINGS_REFERENCE;
|
|
|
+
|
|
|
const string ATLASTXT_WARNING_KEY = "SPINE_ATLASTXT_WARNING";
|
|
|
public static bool atlasTxtImportWarning = SpinePreferences.DEFAULT_ATLASTXT_WARNING;
|
|
|
|
|
@@ -154,6 +157,7 @@ namespace Spine.Unity.Editor {
|
|
|
defaultShader = EditorPrefs.GetString(DEFAULT_SHADER_KEY, SpinePreferences.DEFAULT_DEFAULT_SHADER);
|
|
|
showHierarchyIcons = EditorPrefs.GetBool(SHOW_HIERARCHY_ICONS_KEY, SpinePreferences.DEFAULT_SHOW_HIERARCHY_ICONS);
|
|
|
setTextureImporterSettings = EditorPrefs.GetBool(SET_TEXTUREIMPORTER_SETTINGS_KEY, SpinePreferences.DEFAULT_SET_TEXTUREIMPORTER_SETTINGS);
|
|
|
+ textureSettingsReference = EditorPrefs.GetString(TEXTURE_SETTINGS_REFERENCE_KEY, SpinePreferences.DEFAULT_TEXTURE_SETTINGS_REFERENCE);
|
|
|
autoReloadSceneSkeletons = EditorPrefs.GetBool(AUTO_RELOAD_SCENESKELETONS_KEY, SpinePreferences.DEFAULT_AUTO_RELOAD_SCENESKELETONS);
|
|
|
mecanimEventIncludeFolderName = EditorPrefs.GetBool(MECANIM_EVENT_INCLUDE_FOLDERNAME_KEY, SpinePreferences.DEFAULT_MECANIM_EVENT_INCLUDE_FOLDERNAME);
|
|
|
atlasTxtImportWarning = EditorPrefs.GetBool(ATLASTXT_WARNING_KEY, SpinePreferences.DEFAULT_ATLASTXT_WARNING);
|
|
@@ -171,6 +175,7 @@ namespace Spine.Unity.Editor {
|
|
|
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.textureSettingsReference = EditorPrefs.GetString(TEXTURE_SETTINGS_REFERENCE_KEY, SpinePreferences.DEFAULT_TEXTURE_SETTINGS_REFERENCE);
|
|
|
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);
|
|
@@ -186,6 +191,7 @@ namespace Spine.Unity.Editor {
|
|
|
EditorPrefs.SetString(DEFAULT_SHADER_KEY, preferences.defaultShader);
|
|
|
EditorPrefs.SetBool(SHOW_HIERARCHY_ICONS_KEY, preferences.showHierarchyIcons);
|
|
|
EditorPrefs.SetBool(SET_TEXTUREIMPORTER_SETTINGS_KEY, preferences.setTextureImporterSettings);
|
|
|
+ EditorPrefs.SetString(TEXTURE_SETTINGS_REFERENCE_KEY, preferences.textureSettingsReference);
|
|
|
EditorPrefs.SetBool(AUTO_RELOAD_SCENESKELETONS_KEY, preferences.autoReloadSceneSkeletons);
|
|
|
EditorPrefs.SetBool(MECANIM_EVENT_INCLUDE_FOLDERNAME_KEY, preferences.mecanimEventIncludeFolderName);
|
|
|
EditorPrefs.SetBool(ATLASTXT_WARNING_KEY, preferences.atlasTxtImportWarning);
|
|
@@ -226,6 +232,14 @@ namespace Spine.Unity.Editor {
|
|
|
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);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
@@ -301,7 +315,17 @@ namespace Spine.Unity.Editor {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static void FloatPropertyField(SerializedProperty property, GUIContent label, float min = float.NegativeInfinity, float max = float.PositiveInfinity) {
|
|
|
+ static void Texture2DPrefsField (ref string currentValue, string editorPrefsKey, GUIContent label) {
|
|
|
+ EditorGUI.BeginChangeCheck();
|
|
|
+ EditorGUIUtility.wideMode = true;
|
|
|
+ var texture = (EditorGUILayout.ObjectField(label, AssetDatabase.LoadAssetAtPath<Texture2D>(currentValue), typeof(Object), false) as Texture2D);
|
|
|
+ currentValue = texture != null ? AssetDatabase.GetAssetPath(texture) : "";
|
|
|
+ if (EditorGUI.EndChangeCheck()) {
|
|
|
+ EditorPrefs.SetString(editorPrefsKey, currentValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void FloatPropertyField (SerializedProperty property, GUIContent label, float min = float.NegativeInfinity, float max = float.PositiveInfinity) {
|
|
|
EditorGUI.BeginChangeCheck();
|
|
|
property.floatValue = EditorGUILayout.DelayedFloatField(label, property.floatValue);
|
|
|
if (EditorGUI.EndChangeCheck()) {
|
|
@@ -309,9 +333,15 @@ namespace Spine.Unity.Editor {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static void ShaderPropertyField(SerializedProperty property, GUIContent label, string fallbackShaderName) {
|
|
|
+ public static void ShaderPropertyField (SerializedProperty property, GUIContent label, string fallbackShaderName) {
|
|
|
var shader = (EditorGUILayout.ObjectField(label, Shader.Find(property.stringValue), typeof(Shader), false) as Shader);
|
|
|
property.stringValue = shader != null ? shader.name : fallbackShaderName;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public static void Texture2DPropertyField (SerializedProperty property, GUIContent label) {
|
|
|
+ var texture = (EditorGUILayout.ObjectField(label, AssetDatabase.LoadAssetAtPath<Texture2D>(property.stringValue), typeof(UnityEngine.Object), false) as Texture2D);
|
|
|
+ property.stringValue = texture != null ? AssetDatabase.GetAssetPath(texture) : "";
|
|
|
+ }
|
|
|
}
|
|
|
}
|