mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 09:46:02 +08:00
[unity] More class segregation for SpineEditorUtilities.
This commit is contained in:
parent
2a792c0247
commit
a04242cacf
@ -81,9 +81,7 @@ namespace Spine.Unity.Editor {
|
|||||||
public static Texture2D hingeChain;
|
public static Texture2D hingeChain;
|
||||||
public static Texture2D subMeshRenderer;
|
public static Texture2D subMeshRenderer;
|
||||||
public static Texture2D skeletonDataAssetIcon;
|
public static Texture2D skeletonDataAssetIcon;
|
||||||
|
|
||||||
public static Texture2D info;
|
public static Texture2D info;
|
||||||
|
|
||||||
public static Texture2D unity;
|
public static Texture2D unity;
|
||||||
// public static Texture2D controllerIcon;
|
// public static Texture2D controllerIcon;
|
||||||
|
|
||||||
@ -163,8 +161,6 @@ namespace Spine.Unity.Editor {
|
|||||||
static readonly List<ScriptableObject> protectFromStackGarbageCollection = new List<ScriptableObject>();
|
static readonly List<ScriptableObject> protectFromStackGarbageCollection = new List<ScriptableObject>();
|
||||||
static HashSet<string> assetsImportedInWrongState = new HashSet<string>();
|
static HashSet<string> assetsImportedInWrongState = new HashSet<string>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if SPINE_TK2D
|
#if SPINE_TK2D
|
||||||
const float DEFAULT_DEFAULT_SCALE = 1f;
|
const float DEFAULT_DEFAULT_SCALE = 1f;
|
||||||
#else
|
#else
|
||||||
@ -189,6 +185,10 @@ namespace Spine.Unity.Editor {
|
|||||||
const string SHOW_HIERARCHY_ICONS_KEY = "SPINE_SHOW_HIERARCHY_ICONS";
|
const string SHOW_HIERARCHY_ICONS_KEY = "SPINE_SHOW_HIERARCHY_ICONS";
|
||||||
public static bool showHierarchyIcons = DEFAULT_SHOW_HIERARCHY_ICONS;
|
public static bool showHierarchyIcons = DEFAULT_SHOW_HIERARCHY_ICONS;
|
||||||
|
|
||||||
|
const bool DEFAULT_SET_TEXTUREIMPORTER_SETTINGS = true;
|
||||||
|
const string SET_TEXTUREIMPORTER_SETTINGS_KEY = "SPINE_SET_TEXTUREIMPORTER_SETTINGS";
|
||||||
|
public static bool setTextureImporterSettings = DEFAULT_SET_TEXTUREIMPORTER_SETTINGS;
|
||||||
|
|
||||||
internal const float DEFAULT_MIPMAPBIAS = -0.5f;
|
internal const float DEFAULT_MIPMAPBIAS = -0.5f;
|
||||||
|
|
||||||
public const float DEFAULT_SCENE_ICONS_SCALE = 1f;
|
public const float DEFAULT_SCENE_ICONS_SCALE = 1f;
|
||||||
@ -205,6 +205,7 @@ namespace Spine.Unity.Editor {
|
|||||||
defaultZSpacing = EditorPrefs.GetFloat(DEFAULT_ZSPACING_KEY, DEFAULT_DEFAULT_ZSPACING);
|
defaultZSpacing = EditorPrefs.GetFloat(DEFAULT_ZSPACING_KEY, DEFAULT_DEFAULT_ZSPACING);
|
||||||
defaultShader = EditorPrefs.GetString(DEFAULT_SHADER_KEY, DEFAULT_DEFAULT_SHADER);
|
defaultShader = EditorPrefs.GetString(DEFAULT_SHADER_KEY, DEFAULT_DEFAULT_SHADER);
|
||||||
showHierarchyIcons = EditorPrefs.GetBool(SHOW_HIERARCHY_ICONS_KEY, DEFAULT_SHOW_HIERARCHY_ICONS);
|
showHierarchyIcons = EditorPrefs.GetBool(SHOW_HIERARCHY_ICONS_KEY, DEFAULT_SHOW_HIERARCHY_ICONS);
|
||||||
|
setTextureImporterSettings = EditorPrefs.GetBool(SET_TEXTUREIMPORTER_SETTINGS_KEY, DEFAULT_SET_TEXTUREIMPORTER_SETTINGS);
|
||||||
SpineHandles.handleScale = EditorPrefs.GetFloat(SCENE_ICONS_SCALE_KEY, DEFAULT_SCENE_ICONS_SCALE);
|
SpineHandles.handleScale = EditorPrefs.GetFloat(SCENE_ICONS_SCALE_KEY, DEFAULT_SCENE_ICONS_SCALE);
|
||||||
preferencesLoaded = true;
|
preferencesLoaded = true;
|
||||||
}
|
}
|
||||||
@ -285,6 +286,13 @@ namespace Spine.Unity.Editor {
|
|||||||
EditorPrefs.SetString(DEFAULT_SHADER_KEY, defaultShader);
|
EditorPrefs.SetString(DEFAULT_SHADER_KEY, defaultShader);
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
|
setTextureImporterSettings = EditorGUILayout.Toggle(new GUIContent("Apply Atlas Texture Settings", "Apply the recommended settings for Texture Importers."), showHierarchyIcons);
|
||||||
|
if (EditorGUI.EndChangeCheck()) {
|
||||||
|
EditorPrefs.SetBool(SET_TEXTUREIMPORTER_SETTINGS_KEY, showHierarchyIcons);
|
||||||
|
SpineEditorHierarchyHandler.HierarchyIconsOnPlaymodeStateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
EditorGUILayout.LabelField("Editor Instantiation", EditorStyles.boldLabel);
|
EditorGUILayout.LabelField("Editor Instantiation", EditorStyles.boldLabel);
|
||||||
EditorGUI.BeginChangeCheck();
|
EditorGUI.BeginChangeCheck();
|
||||||
defaultZSpacing = EditorGUILayout.Slider("Default Slot Z-Spacing", defaultZSpacing, -0.1f, 0f);
|
defaultZSpacing = EditorGUILayout.Slider("Default Slot Z-Spacing", defaultZSpacing, -0.1f, 0f);
|
||||||
@ -308,9 +316,9 @@ namespace Spine.Unity.Editor {
|
|||||||
using (new GUILayout.HorizontalScope()) {
|
using (new GUILayout.HorizontalScope()) {
|
||||||
EditorGUILayout.PrefixLabel("Define TK2D");
|
EditorGUILayout.PrefixLabel("Define TK2D");
|
||||||
if (GUILayout.Button("Enable", GUILayout.Width(64)))
|
if (GUILayout.Button("Enable", GUILayout.Width(64)))
|
||||||
EnableTK2D();
|
SpineTK2DEditorUtility.EnableTK2D();
|
||||||
if (GUILayout.Button("Disable", GUILayout.Width(64)))
|
if (GUILayout.Button("Disable", GUILayout.Width(64)))
|
||||||
DisableTK2D();
|
SpineTK2DEditorUtility.DisableTK2D();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -624,12 +632,12 @@ namespace Spine.Unity.Editor {
|
|||||||
break;
|
break;
|
||||||
case ".json":
|
case ".json":
|
||||||
var jsonAsset = (TextAsset)AssetDatabase.LoadAssetAtPath(str, typeof(TextAsset));
|
var jsonAsset = (TextAsset)AssetDatabase.LoadAssetAtPath(str, typeof(TextAsset));
|
||||||
if (jsonAsset != null && IsSpineData(jsonAsset))
|
if (jsonAsset != null && SkeletonDataFileValidator.IsSpineData(jsonAsset))
|
||||||
skeletonPaths.Add(str);
|
skeletonPaths.Add(str);
|
||||||
break;
|
break;
|
||||||
case ".bytes":
|
case ".bytes":
|
||||||
if (str.ToLower().EndsWith(".skel.bytes", System.StringComparison.Ordinal)) {
|
if (str.ToLower().EndsWith(".skel.bytes", System.StringComparison.Ordinal)) {
|
||||||
if (IsSpineData((TextAsset)AssetDatabase.LoadAssetAtPath(str, typeof(TextAsset))))
|
if (SkeletonDataFileValidator.IsSpineData((TextAsset)AssetDatabase.LoadAssetAtPath(str, typeof(TextAsset))))
|
||||||
skeletonPaths.Add(str);
|
skeletonPaths.Add(str);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -647,7 +655,7 @@ namespace Spine.Unity.Editor {
|
|||||||
// Import skeletons and match them with atlases.
|
// Import skeletons and match them with atlases.
|
||||||
bool abortSkeletonImport = false;
|
bool abortSkeletonImport = false;
|
||||||
foreach (string sp in skeletonPaths) {
|
foreach (string sp in skeletonPaths) {
|
||||||
if (!reimport && CheckForValidSkeletonData(sp)) {
|
if (!reimport && SkeletonDataFileValidator.CheckForValidSkeletonData(sp)) {
|
||||||
ReloadSkeletonData(sp);
|
ReloadSkeletonData(sp);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -770,7 +778,6 @@ namespace Spine.Unity.Editor {
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Match SkeletonData with Atlases
|
#region Match SkeletonData with Atlases
|
||||||
//static readonly AttachmentType[] NonAtlasTypes = { AttachmentType.Boundingbox, AttachmentType.Path };
|
|
||||||
static readonly AttachmentType[] AtlasTypes = { AttachmentType.Region, AttachmentType.Linkedmesh, AttachmentType.Mesh };
|
static readonly AttachmentType[] AtlasTypes = { AttachmentType.Region, AttachmentType.Linkedmesh, AttachmentType.Mesh };
|
||||||
|
|
||||||
static List<AtlasAsset> MultiAtlasDialog (List<string> requiredPaths, string initialDirectory, string filename = "") {
|
static List<AtlasAsset> MultiAtlasDialog (List<string> requiredPaths, string initialDirectory, string filename = "") {
|
||||||
@ -1042,28 +1049,25 @@ namespace Spine.Unity.Editor {
|
|||||||
string texturePath = assetPath + "/" + pageFiles[i];
|
string texturePath = assetPath + "/" + pageFiles[i];
|
||||||
Texture2D texture = (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D));
|
Texture2D texture = (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D));
|
||||||
|
|
||||||
TextureImporter texImporter = (TextureImporter)TextureImporter.GetAtPath(texturePath);
|
if (setTextureImporterSettings) {
|
||||||
if (texImporter == null) {
|
TextureImporter texImporter = (TextureImporter)TextureImporter.GetAtPath(texturePath);
|
||||||
Debug.LogWarning(string.Format("{0} ::: Texture asset \"{1}\" not found. Skipping. Please check your atlas file for renamed files.", atlasAsset.name, texturePath));
|
if (texImporter == null) {
|
||||||
continue;
|
Debug.LogWarning(string.Format("{0} ::: Texture asset \"{1}\" not found. Skipping. Please check your atlas file for renamed files.", atlasAsset.name, texturePath));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
texImporter.textureCompression = TextureImporterCompression.Uncompressed;
|
||||||
|
texImporter.alphaSource = TextureImporterAlphaSource.FromInput;
|
||||||
|
texImporter.mipmapEnabled = false;
|
||||||
|
texImporter.alphaIsTransparency = false; // Prevent the texture importer from applying bleed to the transparent parts for PMA.
|
||||||
|
texImporter.spriteImportMode = SpriteImportMode.None;
|
||||||
|
texImporter.maxTextureSize = 2048;
|
||||||
|
|
||||||
|
EditorUtility.SetDirty(texImporter);
|
||||||
|
AssetDatabase.ImportAsset(texturePath);
|
||||||
|
AssetDatabase.SaveAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_5_5_OR_NEWER
|
|
||||||
texImporter.textureCompression = TextureImporterCompression.Uncompressed;
|
|
||||||
texImporter.alphaSource = TextureImporterAlphaSource.FromInput;
|
|
||||||
#else
|
|
||||||
texImporter.textureType = TextureImporterType.Advanced;
|
|
||||||
texImporter.textureFormat = TextureImporterFormat.AutomaticTruecolor;
|
|
||||||
#endif
|
|
||||||
texImporter.mipmapEnabled = false;
|
|
||||||
texImporter.alphaIsTransparency = false; // Prevent the texture importer from applying bleed to the transparent parts.
|
|
||||||
texImporter.spriteImportMode = SpriteImportMode.None;
|
|
||||||
texImporter.maxTextureSize = 2048;
|
|
||||||
|
|
||||||
EditorUtility.SetDirty(texImporter);
|
|
||||||
AssetDatabase.ImportAsset(texturePath);
|
|
||||||
AssetDatabase.SaveAssets();
|
|
||||||
|
|
||||||
string pageName = Path.GetFileNameWithoutExtension(pageFiles[i]);
|
string pageName = Path.GetFileNameWithoutExtension(pageFiles[i]);
|
||||||
|
|
||||||
//because this looks silly
|
//because this looks silly
|
||||||
@ -1116,7 +1120,7 @@ namespace Spine.Unity.Editor {
|
|||||||
bool hasBakedRegions = false;
|
bool hasBakedRegions = false;
|
||||||
for (int i = 0; i < regions.Count; i++) {
|
for (int i = 0; i < regions.Count; i++) {
|
||||||
AtlasRegion region = regions[i];
|
AtlasRegion region = regions[i];
|
||||||
string bakedPrefabPath = Path.Combine(bakedDirPath, SpineEditorUtilities.GetPathSafeRegionName(region) + ".prefab").Replace("\\", "/");
|
string bakedPrefabPath = Path.Combine(bakedDirPath, SpineEditorUtilities.GetPathSafeName(region.name) + ".prefab").Replace("\\", "/");
|
||||||
GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath(bakedPrefabPath, typeof(GameObject));
|
GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath(bakedPrefabPath, typeof(GameObject));
|
||||||
if (prefab != null) {
|
if (prefab != null) {
|
||||||
BakeRegion(atlasAsset, region, false);
|
BakeRegion(atlasAsset, region, false);
|
||||||
@ -1140,7 +1144,7 @@ namespace Spine.Unity.Editor {
|
|||||||
string atlasAssetPath = AssetDatabase.GetAssetPath(atlasAsset);
|
string atlasAssetPath = AssetDatabase.GetAssetPath(atlasAsset);
|
||||||
string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath);
|
string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath);
|
||||||
string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name);
|
string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name);
|
||||||
string bakedPrefabPath = Path.Combine(bakedDirPath, GetPathSafeRegionName(region) + ".prefab").Replace("\\", "/");
|
string bakedPrefabPath = Path.Combine(bakedDirPath, GetPathSafeName(region.name) + ".prefab").Replace("\\", "/");
|
||||||
|
|
||||||
GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath(bakedPrefabPath, typeof(GameObject));
|
GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath(bakedPrefabPath, typeof(GameObject));
|
||||||
GameObject root;
|
GameObject root;
|
||||||
@ -1239,126 +1243,103 @@ namespace Spine.Unity.Editor {
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Checking Methods
|
#region SkeletonDataFileValidator
|
||||||
static int[][] compatibleBinaryVersions = { new[] {3, 6, 0}, new[] {3, 5, 0} };
|
internal static class SkeletonDataFileValidator {
|
||||||
static int[][] compatibleJsonVersions = { new[] { 3, 6, 0 }, new[] { 3, 7, 0 }, new[] { 3, 5, 0 } };
|
static int[][] compatibleBinaryVersions = { new[] { 3, 6, 0 }, new[] { 3, 5, 0 } };
|
||||||
//static bool isFixVersionRequired = false;
|
static int[][] compatibleJsonVersions = { new[] { 3, 6, 0 }, new[] { 3, 7, 0 }, new[] { 3, 5, 0 } };
|
||||||
|
//static bool isFixVersionRequired = false;
|
||||||
|
|
||||||
static bool CheckForValidSkeletonData (string skeletonJSONPath) {
|
public static bool CheckForValidSkeletonData (string skeletonJSONPath) {
|
||||||
string dir = Path.GetDirectoryName(skeletonJSONPath);
|
string dir = Path.GetDirectoryName(skeletonJSONPath);
|
||||||
TextAsset textAsset = (TextAsset)AssetDatabase.LoadAssetAtPath(skeletonJSONPath, typeof(TextAsset));
|
TextAsset textAsset = (TextAsset)AssetDatabase.LoadAssetAtPath(skeletonJSONPath, typeof(TextAsset));
|
||||||
DirectoryInfo dirInfo = new DirectoryInfo(dir);
|
DirectoryInfo dirInfo = new DirectoryInfo(dir);
|
||||||
FileInfo[] files = dirInfo.GetFiles("*.asset");
|
FileInfo[] files = dirInfo.GetFiles("*.asset");
|
||||||
|
|
||||||
foreach (var path in files) {
|
foreach (var path in files) {
|
||||||
string localPath = dir + "/" + path.Name;
|
string localPath = dir + "/" + path.Name;
|
||||||
var obj = AssetDatabase.LoadAssetAtPath(localPath, typeof(Object));
|
var obj = AssetDatabase.LoadAssetAtPath(localPath, typeof(Object));
|
||||||
var skeletonDataAsset = obj as SkeletonDataAsset;
|
var skeletonDataAsset = obj as SkeletonDataAsset;
|
||||||
if (skeletonDataAsset != null && skeletonDataAsset.skeletonJSON == textAsset)
|
if (skeletonDataAsset != null && skeletonDataAsset.skeletonJSON == textAsset)
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
public static bool IsSpineData (TextAsset asset) {
|
||||||
}
|
if (asset == null)
|
||||||
|
|
||||||
public static bool IsSpineData (TextAsset asset) {
|
|
||||||
if (asset == null) return false;
|
|
||||||
|
|
||||||
bool isSpineData = false;
|
|
||||||
string rawVersion = null;
|
|
||||||
|
|
||||||
int[][] compatibleVersions;
|
|
||||||
if (asset.name.Contains(".skel")) {
|
|
||||||
try {
|
|
||||||
rawVersion = SkeletonBinary.GetVersionString(new MemoryStream(asset.bytes));
|
|
||||||
isSpineData = !(string.IsNullOrEmpty(rawVersion));
|
|
||||||
compatibleVersions = compatibleBinaryVersions;
|
|
||||||
} catch (System.Exception e) {
|
|
||||||
Debug.LogErrorFormat("Failed to read '{0}'. It is likely not a binary Spine SkeletonData file.\n{1}", asset.name, e);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
object obj = Json.Deserialize(new StringReader(asset.text));
|
|
||||||
if (obj == null) {
|
|
||||||
Debug.LogErrorFormat("'{0}' is not valid JSON.", asset.name);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var root = obj as Dictionary<string, object>;
|
bool isSpineData = false;
|
||||||
if (root == null) {
|
string rawVersion = null;
|
||||||
Debug.LogError("Parser returned an incorrect type.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
isSpineData = root.ContainsKey("skeleton");
|
int[][] compatibleVersions;
|
||||||
if (isSpineData) {
|
if (asset.name.Contains(".skel")) {
|
||||||
var skeletonInfo = (Dictionary<string, object>)root["skeleton"];
|
try {
|
||||||
object jv;
|
rawVersion = SkeletonBinary.GetVersionString(new MemoryStream(asset.bytes));
|
||||||
skeletonInfo.TryGetValue("spine", out jv);
|
isSpineData = !(string.IsNullOrEmpty(rawVersion));
|
||||||
rawVersion = jv as string;
|
compatibleVersions = compatibleBinaryVersions;
|
||||||
}
|
} catch (System.Exception e) {
|
||||||
|
Debug.LogErrorFormat("Failed to read '{0}'. It is likely not a binary Spine SkeletonData file.\n{1}", asset.name, e);
|
||||||
compatibleVersions = compatibleJsonVersions;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Version warning
|
|
||||||
if (isSpineData) {
|
|
||||||
string primaryRuntimeVersionDebugString = compatibleVersions[0][0] + "." + compatibleVersions[0][1];
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(rawVersion)) {
|
|
||||||
Debug.LogWarningFormat("Skeleton '{0}' has no version information. It may be incompatible with your runtime version: spine-unity v{1}", asset.name, primaryRuntimeVersionDebugString);
|
|
||||||
} else {
|
} else {
|
||||||
string[] versionSplit = rawVersion.Split('.');
|
object obj = Json.Deserialize(new StringReader(asset.text));
|
||||||
bool match = false;
|
if (obj == null) {
|
||||||
foreach (var version in compatibleVersions) {
|
Debug.LogErrorFormat("'{0}' is not valid JSON.", asset.name);
|
||||||
bool primaryMatch = version[0] == int.Parse(versionSplit[0]);
|
return false;
|
||||||
bool secondaryMatch = version[1] == int.Parse(versionSplit[1]);
|
|
||||||
|
|
||||||
// if (isFixVersionRequired) secondaryMatch &= version[2] <= int.Parse(jsonVersionSplit[2]);
|
|
||||||
|
|
||||||
if (primaryMatch && secondaryMatch) {
|
|
||||||
match = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!match)
|
var root = obj as Dictionary<string, object>;
|
||||||
Debug.LogWarningFormat("Skeleton '{0}' (exported with Spine {1}) may be incompatible with your runtime version: spine-unity v{2}", asset.name, rawVersion, primaryRuntimeVersionDebugString);
|
if (root == null) {
|
||||||
}
|
Debug.LogError("Parser returned an incorrect type.");
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return isSpineData;
|
isSpineData = root.ContainsKey("skeleton");
|
||||||
|
if (isSpineData) {
|
||||||
|
var skeletonInfo = (Dictionary<string, object>)root["skeleton"];
|
||||||
|
object jv;
|
||||||
|
skeletonInfo.TryGetValue("spine", out jv);
|
||||||
|
rawVersion = jv as string;
|
||||||
|
}
|
||||||
|
|
||||||
|
compatibleVersions = compatibleJsonVersions;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Version warning
|
||||||
|
if (isSpineData) {
|
||||||
|
string primaryRuntimeVersionDebugString = compatibleVersions[0][0] + "." + compatibleVersions[0][1];
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(rawVersion)) {
|
||||||
|
Debug.LogWarningFormat("Skeleton '{0}' has no version information. It may be incompatible with your runtime version: spine-unity v{1}", asset.name, primaryRuntimeVersionDebugString);
|
||||||
|
} else {
|
||||||
|
string[] versionSplit = rawVersion.Split('.');
|
||||||
|
bool match = false;
|
||||||
|
foreach (var version in compatibleVersions) {
|
||||||
|
bool primaryMatch = version[0] == int.Parse(versionSplit[0]);
|
||||||
|
bool secondaryMatch = version[1] == int.Parse(versionSplit[1]);
|
||||||
|
|
||||||
|
// if (isFixVersionRequired) secondaryMatch &= version[2] <= int.Parse(jsonVersionSplit[2]);
|
||||||
|
|
||||||
|
if (primaryMatch && secondaryMatch) {
|
||||||
|
match = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!match)
|
||||||
|
Debug.LogWarningFormat("Skeleton '{0}' (exported with Spine {1}) may be incompatible with your runtime version: spine-unity v{2}", asset.name, rawVersion, primaryRuntimeVersionDebugString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return isSpineData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region SkeletonAnimation Menu
|
#region SkeletonAnimation Menu
|
||||||
// [MenuItem("Assets/Spine/Instantiate (SkeletonAnimation)", false, 10)]
|
|
||||||
// static void InstantiateSkeletonAnimation () {
|
|
||||||
// Object[] arr = Selection.objects;
|
|
||||||
// foreach (Object o in arr) {
|
|
||||||
// string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(o));
|
|
||||||
// string skinName = EditorPrefs.GetString(guid + "_lastSkin", "");
|
|
||||||
//
|
|
||||||
// InstantiateSkeletonAnimation((SkeletonDataAsset)o, skinName, false);
|
|
||||||
// SceneView.RepaintAll();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// [MenuItem("Assets/Spine/Instantiate (SkeletonAnimation)", true, 10)]
|
|
||||||
// static bool ValidateInstantiateSkeletonAnimation () {
|
|
||||||
// Object[] arr = Selection.objects;
|
|
||||||
//
|
|
||||||
// if (arr.Length == 0)
|
|
||||||
// return false;
|
|
||||||
//
|
|
||||||
// foreach (Object o in arr) {
|
|
||||||
// if (o.GetType() != typeof(SkeletonDataAsset))
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public static void IngestAdvancedRenderSettings (SkeletonRenderer skeletonRenderer) {
|
public static void IngestAdvancedRenderSettings (SkeletonRenderer skeletonRenderer) {
|
||||||
const string PMAShaderQuery = "Spine/Skeleton";
|
const string PMAShaderQuery = "Spine/Skeleton";
|
||||||
const string TintBlackShaderQuery = "Tint Black";
|
const string TintBlackShaderQuery = "Tint Black";
|
||||||
@ -1501,74 +1482,80 @@ namespace Spine.Unity.Editor {
|
|||||||
|
|
||||||
return anim;
|
return anim;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region TK2D Support
|
#region SpineTK2DEditorUtility
|
||||||
const string SPINE_TK2D_DEFINE = "SPINE_TK2D";
|
internal static class SpineTK2DEditorUtility {
|
||||||
|
const string SPINE_TK2D_DEFINE = "SPINE_TK2D";
|
||||||
|
|
||||||
static bool IsInvalidGroup (BuildTargetGroup group) {
|
static bool IsInvalidGroup (BuildTargetGroup group) {
|
||||||
int gi = (int)group;
|
int gi = (int)group;
|
||||||
return
|
return
|
||||||
gi == 15 || gi == 16
|
gi == 15 || gi == 16
|
||||||
||
|
||
|
||||||
group == BuildTargetGroup.Unknown;
|
group == BuildTargetGroup.Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void EnableTK2D () {
|
internal static void EnableTK2D () {
|
||||||
bool added = false;
|
bool added = false;
|
||||||
foreach (BuildTargetGroup group in System.Enum.GetValues(typeof(BuildTargetGroup))) {
|
foreach (BuildTargetGroup group in System.Enum.GetValues(typeof(BuildTargetGroup))) {
|
||||||
if (IsInvalidGroup(group))
|
if (IsInvalidGroup(group))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
|
string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
|
||||||
if (!defines.Contains(SPINE_TK2D_DEFINE)) {
|
if (!defines.Contains(SPINE_TK2D_DEFINE)) {
|
||||||
added = true;
|
added = true;
|
||||||
if (defines.EndsWith(";", System.StringComparison.Ordinal))
|
if (defines.EndsWith(";", System.StringComparison.Ordinal))
|
||||||
defines = defines + SPINE_TK2D_DEFINE;
|
defines = defines + SPINE_TK2D_DEFINE;
|
||||||
else
|
else
|
||||||
defines = defines + ";" + SPINE_TK2D_DEFINE;
|
defines = defines + ";" + SPINE_TK2D_DEFINE;
|
||||||
|
|
||||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(group, defines);
|
PlayerSettings.SetScriptingDefineSymbolsForGroup(group, defines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (added) {
|
||||||
|
Debug.LogWarning("Setting Scripting Define Symbol " + SPINE_TK2D_DEFINE);
|
||||||
|
} else {
|
||||||
|
Debug.LogWarning("Already Set Scripting Define Symbol " + SPINE_TK2D_DEFINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (added) {
|
|
||||||
Debug.LogWarning("Setting Scripting Define Symbol " + SPINE_TK2D_DEFINE);
|
|
||||||
} else {
|
|
||||||
Debug.LogWarning("Already Set Scripting Define Symbol " + SPINE_TK2D_DEFINE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
internal static void DisableTK2D () {
|
||||||
|
bool removed = false;
|
||||||
|
foreach (BuildTargetGroup group in System.Enum.GetValues(typeof(BuildTargetGroup))) {
|
||||||
|
if (IsInvalidGroup(group))
|
||||||
|
continue;
|
||||||
|
|
||||||
static void DisableTK2D () {
|
string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
|
||||||
bool removed = false;
|
if (defines.Contains(SPINE_TK2D_DEFINE)) {
|
||||||
foreach (BuildTargetGroup group in System.Enum.GetValues(typeof(BuildTargetGroup))) {
|
removed = true;
|
||||||
if (IsInvalidGroup(group))
|
if (defines.Contains(SPINE_TK2D_DEFINE + ";"))
|
||||||
continue;
|
defines = defines.Replace(SPINE_TK2D_DEFINE + ";", "");
|
||||||
|
else
|
||||||
|
defines = defines.Replace(SPINE_TK2D_DEFINE, "");
|
||||||
|
|
||||||
string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
|
PlayerSettings.SetScriptingDefineSymbolsForGroup(group, defines);
|
||||||
if (defines.Contains(SPINE_TK2D_DEFINE)) {
|
}
|
||||||
removed = true;
|
|
||||||
if (defines.Contains(SPINE_TK2D_DEFINE + ";"))
|
|
||||||
defines = defines.Replace(SPINE_TK2D_DEFINE + ";", "");
|
|
||||||
else
|
|
||||||
defines = defines.Replace(SPINE_TK2D_DEFINE, "");
|
|
||||||
|
|
||||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(group, defines);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (removed) {
|
if (removed) {
|
||||||
Debug.LogWarning("Removing Scripting Define Symbol " + SPINE_TK2D_DEFINE);
|
Debug.LogWarning("Removing Scripting Define Symbol " + SPINE_TK2D_DEFINE);
|
||||||
} else {
|
} else {
|
||||||
Debug.LogWarning("Already Removed Scripting Define Symbol " + SPINE_TK2D_DEFINE);
|
Debug.LogWarning("Already Removed Scripting Define Symbol " + SPINE_TK2D_DEFINE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public static string GetPathSafeRegionName (AtlasRegion region) {
|
//public static string GetPathSafeRegionName (AtlasRegion region) {
|
||||||
return region.name.Replace("/", "_");
|
// return region.name.Replace("/", "_");
|
||||||
|
//}
|
||||||
|
|
||||||
|
public static string GetPathSafeName (string name) {
|
||||||
|
return name.Replace("/", "_");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user