mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[unity] Reorganize SpineEditorUtilities.
This commit is contained in:
parent
a070b0fd9f
commit
dd888a356e
@ -111,7 +111,7 @@ namespace Spine.Unity.Editor {
|
||||
EditorGUILayout.HelpBox(string.Format("Animation named {0} was not found for this Skeleton.", animationNameProperty.stringValue), MessageType.Warning);
|
||||
} else {
|
||||
using (new SpineInspectorUtility.BoxScope()) {
|
||||
if (!string.Equals(SpineEditorUtilities.GetPathSafeName(animationName), ThisAnimationReferenceAsset.name, System.StringComparison.OrdinalIgnoreCase))
|
||||
if (!string.Equals(SpineEditorUtilities.AssetUtility.GetPathSafeName(animationName), ThisAnimationReferenceAsset.name, System.StringComparison.OrdinalIgnoreCase))
|
||||
EditorGUILayout.HelpBox("Animation name value does not match this asset's name. Inspectors using this asset may be misleading.", MessageType.None);
|
||||
|
||||
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent(animationName, SpineEditorUtilities.Icons.animation));
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
|
||||
// Contributed by: Mitch Thompson
|
||||
|
||||
#define SPINE_SKELETON_ANIMATOR
|
||||
#define SPINE_SKELETONMECANIM
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
@ -71,7 +71,14 @@ namespace Spine.Unity.Editor {
|
||||
public static class SkeletonBaker {
|
||||
|
||||
#region SkeletonAnimator's Mecanim Clips
|
||||
#if SPINE_SKELETON_ANIMATOR
|
||||
#if SPINE_SKELETONMECANIM
|
||||
public static void UpdateMecanimClips (SkeletonDataAsset skeletonDataAsset) {
|
||||
if (skeletonDataAsset.controller == null)
|
||||
return;
|
||||
|
||||
SkeletonBaker.GenerateMecanimAnimationClips(skeletonDataAsset);
|
||||
}
|
||||
|
||||
public static void GenerateMecanimAnimationClips (SkeletonDataAsset skeletonDataAsset) {
|
||||
var data = skeletonDataAsset.GetSkeletonData(true);
|
||||
if (data == null) {
|
||||
@ -1413,7 +1420,7 @@ namespace Spine.Unity.Editor {
|
||||
string atlasAssetPath = AssetDatabase.GetAssetPath(atlasAsset);
|
||||
string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath);
|
||||
string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name);
|
||||
string bakedPrefabPath = Path.Combine(bakedDirPath, SpineEditorUtilities.GetPathSafeName(region.name) + ".prefab").Replace("\\", "/");
|
||||
string bakedPrefabPath = Path.Combine(bakedDirPath, SpineEditorUtilities.AssetUtility.GetPathSafeName(region.name) + ".prefab").Replace("\\", "/");
|
||||
|
||||
GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath(bakedPrefabPath, typeof(GameObject));
|
||||
GameObject root;
|
||||
|
||||
@ -238,7 +238,7 @@ namespace Spine.Unity.Editor {
|
||||
FieldInfo nameField = typeof(AnimationReferenceAsset).GetField("animationName", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
FieldInfo skeletonDataAssetField = typeof(AnimationReferenceAsset).GetField("skeletonDataAsset", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
foreach (var animation in targetSkeletonData.Animations) {
|
||||
string assetPath = string.Format("{0}/{1}.asset", dataPath, SpineEditorUtilities.GetPathSafeName(animation.Name));
|
||||
string assetPath = string.Format("{0}/{1}.asset", dataPath, SpineEditorUtilities.AssetUtility.GetPathSafeName(animation.Name));
|
||||
AnimationReferenceAsset existingAsset = AssetDatabase.LoadAssetAtPath<AnimationReferenceAsset>(assetPath);
|
||||
if (existingAsset == null) {
|
||||
AnimationReferenceAsset newAsset = ScriptableObject.CreateInstance<AnimationReferenceAsset>();
|
||||
@ -538,8 +538,8 @@ namespace Spine.Unity.Editor {
|
||||
warnings.Add("Missing Skeleton JSON");
|
||||
} else {
|
||||
var fieldValue = (TextAsset)skeletonJSON.objectReferenceValue;
|
||||
if (!SpineEditorUtilities.SkeletonDataFileValidator.IsSpineData(fieldValue)) {
|
||||
warnings.Add("Skeleton data file is not a valid JSON or binary file.");
|
||||
if (!SpineEditorUtilities.AssetUtility.IsSpineData(fieldValue)) {
|
||||
warnings.Add("Skeleton data file is not a valid Spine JSON or binary file.");
|
||||
} else {
|
||||
#if SPINE_TK2D
|
||||
bool searchForSpineAtlasAssets = true;
|
||||
@ -769,7 +769,7 @@ namespace Spine.Unity.Editor {
|
||||
|
||||
if (previewGameObject == null) {
|
||||
try {
|
||||
previewGameObject = SpineEditorUtilities.InstantiateSkeletonAnimation(skeletonDataAsset, skinName).gameObject;
|
||||
previewGameObject = SpineEditorUtilities.EditorInstantiation.InstantiateSkeletonAnimation(skeletonDataAsset, skinName).gameObject;
|
||||
|
||||
if (previewGameObject != null) {
|
||||
previewGameObject.hideFlags = HideFlags.HideAndDontSave;
|
||||
|
||||
@ -93,7 +93,7 @@ namespace Spine.Unity.Editor {
|
||||
string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name);
|
||||
for (int i = 0; i < regions.Count; i++) {
|
||||
AtlasRegion region = regions[i];
|
||||
string bakedPrefabPath = Path.Combine(bakedDirPath, SpineEditorUtilities.GetPathSafeRegionName(region) + ".prefab").Replace("\\", "/");
|
||||
string bakedPrefabPath = Path.Combine(bakedDirPath, SpineEditorUtilities.AssetUtility.GetPathSafeRegionName(region) + ".prefab").Replace("\\", "/");
|
||||
GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath(bakedPrefabPath, typeof(GameObject));
|
||||
baked.Add(prefab != null);
|
||||
bakedObjects.Add(prefab);
|
||||
@ -134,12 +134,12 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
if (SpineInspectorUtility.LargeCenteredButton(SpineInspectorUtility.TempContent("Set Mipmap Bias to " + SpineEditorUtilities.DEFAULT_MIPMAPBIAS))) {
|
||||
if (SpineInspectorUtility.LargeCenteredButton(SpineInspectorUtility.TempContent("Set Mipmap Bias to " + SpineEditorUtilities.Preferences.DEFAULT_MIPMAPBIAS))) {
|
||||
foreach (var m in atlasAsset.materials) {
|
||||
var texture = m.mainTexture;
|
||||
texture.mipMapBias = SpineEditorUtilities.DEFAULT_MIPMAPBIAS;
|
||||
texture.mipMapBias = SpineEditorUtilities.Preferences.DEFAULT_MIPMAPBIAS;
|
||||
}
|
||||
Debug.Log("Texture mipmap bias set to " + SpineEditorUtilities.DEFAULT_MIPMAPBIAS);
|
||||
Debug.Log("Texture mipmap bias set to " + SpineEditorUtilities.Preferences.DEFAULT_MIPMAPBIAS);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -193,7 +193,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
|
||||
skin = skin ?? data.DefaultSkin ?? data.Skins.Items[0];
|
||||
graphic.MeshGenerator.settings.zSpacing = SpineEditorUtilities.defaultZSpacing;
|
||||
graphic.MeshGenerator.settings.zSpacing = SpineEditorUtilities.Preferences.defaultZSpacing;
|
||||
|
||||
graphic.Initialize(false);
|
||||
if (skin != null) graphic.Skeleton.SetSkin(skin);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user