This commit is contained in:
Mausham
2026-06-25 11:23:34 +05:45
parent 93fafae63b
commit b9c9889145
35 changed files with 1354 additions and 170 deletions

View File

@@ -136,7 +136,7 @@ namespace Spine.Unity.Editor {
if (SpineInspectorUtility.LargeCenteredButton(SpineInspectorUtility.TempContent("Set Mipmap Bias to " + SpinePreferences.DEFAULT_MIPMAPBIAS, tooltip: "This may help textures with mipmaps be less blurry when used for 2D sprites."))) {
foreach (var m in atlasAsset.materials) {
var texture = m.mainTexture;
string texturePath = AssetDatabase.GetAssetPath(texture.GetInstanceID());
string texturePath = AssetDatabase.GetAssetPath(texture.GetEntityId());
var importer = (TextureImporter)TextureImporter.GetAtPath(texturePath);
importer.mipMapBias = SpinePreferences.DEFAULT_MIPMAPBIAS;
EditorUtility.SetDirty(texture);
@@ -313,7 +313,7 @@ namespace Spine.Unity.Editor {
}
static public void UpdateSpriteSlices (Texture texture, Atlas atlas) {
string texturePath = AssetDatabase.GetAssetPath(texture.GetInstanceID());
string texturePath = AssetDatabase.GetAssetPath(texture.GetEntityId());
var t = (TextureImporter)TextureImporter.GetAtPath(texturePath);
t.spriteImportMode = SpriteImportMode.Multiple;
var spriteSheet = t.spritesheet;

View File

@@ -384,7 +384,7 @@ namespace Spine.Unity.Editor {
foreach (var skeletonGraphic in skeletonGraphicObjects) {
if (skeletonGraphic.skeletonDataAsset == null) {
var skeletonGraphicID = skeletonGraphic.GetInstanceID();
var skeletonGraphicID = skeletonGraphic.GetEntityId();
if (SpineEditorUtilities.DataReloadHandler.savedSkeletonDataAssetAtSKeletonGraphicID.ContainsKey(skeletonGraphicID)) {
string assetPath = SpineEditorUtilities.DataReloadHandler.savedSkeletonDataAssetAtSKeletonGraphicID[skeletonGraphicID];
skeletonGraphic.skeletonDataAsset = (SkeletonDataAsset)AssetDatabase.LoadAssetAtPath<SkeletonDataAsset>(assetPath);
@@ -447,9 +447,9 @@ namespace Spine.Unity.Editor {
for (int i = 0; i < skeletonDataAtlasAssets.Length; i++) {
if (!ReferenceEquals(null, skeletonDataAtlasAssets[i]) &&
skeletonDataAtlasAssets[i].Equals(null) &&
skeletonDataAtlasAssets[i].GetInstanceID() != 0
skeletonDataAtlasAssets[i].GetEntityId() != EntityId.None
) {
skeletonDataAtlasAssets[i] = EditorUtility.InstanceIDToObject(skeletonDataAtlasAssets[i].GetInstanceID()) as AtlasAssetBase;
skeletonDataAtlasAssets[i] = EditorUtility.EntityIdToObject(skeletonDataAtlasAssets[i].GetEntityId()) as AtlasAssetBase;
}
}
}

View File

@@ -49,7 +49,7 @@ namespace Spine.Unity.Editor {
public partial class SpineEditorUtilities {
public static class DataReloadHandler {
internal static Dictionary<int, string> savedSkeletonDataAssetAtSKeletonGraphicID = new Dictionary<int, string>();
internal static Dictionary<EntityId, string> savedSkeletonDataAssetAtSKeletonGraphicID = new Dictionary<EntityId, string>();
#if NEWPLAYMODECALLBACKS
internal static void OnPlaymodeStateChanged (PlayModeStateChange stateChange) {
@@ -84,7 +84,7 @@ namespace Spine.Unity.Editor {
var skeletonDataAsset = sg.skeletonDataAsset;
if (skeletonDataAsset != null) {
var assetPath = AssetDatabase.GetAssetPath(skeletonDataAsset);
var sgID = sg.GetInstanceID();
var sgID = sg.GetEntityId();
savedSkeletonDataAssetAtSKeletonGraphicID[sgID] = assetPath;
skeletonDataAssetsToReload.Add(skeletonDataAsset);
}

View File

@@ -134,8 +134,8 @@ namespace Spine.Unity.Editor {
SceneView.onSceneGUIDelegate += DragAndDropInstantiation.SceneViewDragAndDrop;
#endif
EditorApplication.hierarchyWindowItemOnGUI -= HierarchyHandler.HandleDragAndDrop;
EditorApplication.hierarchyWindowItemOnGUI += HierarchyHandler.HandleDragAndDrop;
EditorApplication.hierarchyWindowItemByEntityIdOnGUI -= HierarchyHandler.HandleDragAndDrop;
EditorApplication.hierarchyWindowItemByEntityIdOnGUI += HierarchyHandler.HandleDragAndDrop;
// Hierarchy Icons
#if NEWPLAYMODECALLBACKS
@@ -274,10 +274,10 @@ namespace Spine.Unity.Editor {
#endregion
public static class HierarchyHandler {
static Dictionary<int, GameObject> skeletonRendererTable = new Dictionary<int, GameObject>();
static Dictionary<int, SkeletonUtilityBone> skeletonUtilityBoneTable = new Dictionary<int, SkeletonUtilityBone>();
static Dictionary<int, BoundingBoxFollower> boundingBoxFollowerTable = new Dictionary<int, BoundingBoxFollower>();
static Dictionary<int, BoundingBoxFollowerGraphic> boundingBoxFollowerGraphicTable = new Dictionary<int, BoundingBoxFollowerGraphic>();
static Dictionary<EntityId, GameObject> skeletonRendererTable = new Dictionary<EntityId, GameObject>();
static Dictionary<EntityId, SkeletonUtilityBone> skeletonUtilityBoneTable = new Dictionary<EntityId, SkeletonUtilityBone>();
static Dictionary<EntityId, BoundingBoxFollower> boundingBoxFollowerTable = new Dictionary<EntityId, BoundingBoxFollower>();
static Dictionary<EntityId, BoundingBoxFollowerGraphic> boundingBoxFollowerGraphicTable = new Dictionary<EntityId, BoundingBoxFollowerGraphic>();
#if NEWPLAYMODECALLBACKS
internal static void IconsOnPlaymodeStateChanged (PlayModeStateChange stateChange) {
@@ -294,7 +294,7 @@ namespace Spine.Unity.Editor {
#else
EditorApplication.hierarchyWindowChanged -= IconsOnChanged;
#endif
EditorApplication.hierarchyWindowItemOnGUI -= IconsOnGUI;
EditorApplication.hierarchyWindowItemByEntityIdOnGUI -= IconsOnGUI;
if (!Application.isPlaying && Preferences.showHierarchyIcons) {
#if NEWHIERARCHYWINDOWCALLBACKS
@@ -302,7 +302,7 @@ namespace Spine.Unity.Editor {
#else
EditorApplication.hierarchyWindowChanged += IconsOnChanged;
#endif
EditorApplication.hierarchyWindowItemOnGUI += IconsOnGUI;
EditorApplication.hierarchyWindowItemByEntityIdOnGUI += IconsOnGUI;
IconsOnChanged();
}
}
@@ -315,54 +315,54 @@ namespace Spine.Unity.Editor {
SkeletonRenderer[] arr = Object.FindObjectsOfType<SkeletonRenderer>();
foreach (SkeletonRenderer r in arr)
skeletonRendererTable[r.gameObject.GetInstanceID()] = r.gameObject;
skeletonRendererTable[r.gameObject.GetEntityId()] = r.gameObject;
SkeletonUtilityBone[] boneArr = Object.FindObjectsOfType<SkeletonUtilityBone>();
foreach (SkeletonUtilityBone b in boneArr)
skeletonUtilityBoneTable[b.gameObject.GetInstanceID()] = b;
skeletonUtilityBoneTable[b.gameObject.GetEntityId()] = b;
BoundingBoxFollower[] bbfArr = Object.FindObjectsOfType<BoundingBoxFollower>();
foreach (BoundingBoxFollower bbf in bbfArr)
boundingBoxFollowerTable[bbf.gameObject.GetInstanceID()] = bbf;
boundingBoxFollowerTable[bbf.gameObject.GetEntityId()] = bbf;
BoundingBoxFollowerGraphic[] bbfgArr = Object.FindObjectsOfType<BoundingBoxFollowerGraphic>();
foreach (BoundingBoxFollowerGraphic bbf in bbfgArr)
boundingBoxFollowerGraphicTable[bbf.gameObject.GetInstanceID()] = bbf;
boundingBoxFollowerGraphicTable[bbf.gameObject.GetEntityId()] = bbf;
}
internal static void IconsOnGUI (int instanceId, Rect selectionRect) {
internal static void IconsOnGUI (EntityId entityId, Rect selectionRect) {
Rect r = new Rect(selectionRect);
if (skeletonRendererTable.ContainsKey(instanceId)) {
if (skeletonRendererTable.ContainsKey(entityId)) {
r.x = r.width - 15;
r.width = 15;
GUI.Label(r, Icons.spine);
} else if (skeletonUtilityBoneTable.ContainsKey(instanceId)) {
} else if (skeletonUtilityBoneTable.ContainsKey(entityId)) {
r.x -= 26;
if (skeletonUtilityBoneTable[instanceId] != null) {
if (skeletonUtilityBoneTable[instanceId].transform.childCount == 0)
if (skeletonUtilityBoneTable[entityId] != null) {
if (skeletonUtilityBoneTable[entityId].transform.childCount == 0)
r.x += 13;
r.y += 2;
r.width = 13;
r.height = 13;
if (skeletonUtilityBoneTable[instanceId].mode == SkeletonUtilityBone.Mode.Follow)
if (skeletonUtilityBoneTable[entityId].mode == SkeletonUtilityBone.Mode.Follow)
GUI.DrawTexture(r, Icons.bone);
else
GUI.DrawTexture(r, Icons.poseBones);
}
} else if (boundingBoxFollowerTable.ContainsKey(instanceId)) {
} else if (boundingBoxFollowerTable.ContainsKey(entityId)) {
r.x -= 26;
if (boundingBoxFollowerTable[instanceId] != null) {
if (boundingBoxFollowerTable[instanceId].transform.childCount == 0)
if (boundingBoxFollowerTable[entityId] != null) {
if (boundingBoxFollowerTable[entityId].transform.childCount == 0)
r.x += 13;
r.y += 2;
r.width = 13;
r.height = 13;
GUI.DrawTexture(r, Icons.boundingBox);
}
} else if (boundingBoxFollowerGraphicTable.ContainsKey(instanceId)) {
} else if (boundingBoxFollowerGraphicTable.ContainsKey(entityId)) {
r.x -= 26;
if (boundingBoxFollowerGraphicTable[instanceId] != null) {
if (boundingBoxFollowerGraphicTable[instanceId].transform.childCount == 0)
if (boundingBoxFollowerGraphicTable[entityId] != null) {
if (boundingBoxFollowerGraphicTable[entityId].transform.childCount == 0)
r.x += 13;
r.y += 2;
r.width = 13;
@@ -372,7 +372,7 @@ namespace Spine.Unity.Editor {
}
}
internal static void HandleDragAndDrop (int instanceId, Rect selectionRect) {
internal static void HandleDragAndDrop (EntityId entityId, Rect selectionRect) {
// HACK: Uses EditorApplication.hierarchyWindowItemOnGUI.
// Only works when there is at least one item in the scene.
var current = UnityEngine.Event.current;
@@ -397,7 +397,7 @@ namespace Spine.Unity.Editor {
const string GenericDataTargetID = "target";
if (HierarchyWindow.Equals(mouseOverWindow.GetType().ToString(), System.StringComparison.Ordinal)) {
if (isDraggingEvent) {
var mouseOverTarget = UnityEditor.EditorUtility.InstanceIDToObject(instanceId);
var mouseOverTarget = UnityEditor.EditorUtility.EntityIdToObject(entityId);
if (mouseOverTarget)
DragAndDrop.SetGenericData(GenericDataTargetID, mouseOverTarget);
// Note: do not call current.Use(), otherwise we get the wrong drop-target parent.

View File

@@ -646,8 +646,8 @@ namespace Spine.Unity {
class AnimationClipEqualityComparer : IEqualityComparer<AnimationClip> {
internal static readonly IEqualityComparer<AnimationClip> Instance = new AnimationClipEqualityComparer();
public bool Equals (AnimationClip x, AnimationClip y) { return x.GetInstanceID() == y.GetInstanceID(); }
public int GetHashCode (AnimationClip o) { return o.GetInstanceID(); }
public bool Equals (AnimationClip x, AnimationClip y) { return x.GetEntityId().Equals(y.GetEntityId()); }
public int GetHashCode (AnimationClip o) { return o.GetEntityId().GetHashCode(); }
}
class IntEqualityComparer : IEqualityComparer<int> {