[unity] Fixed Perforce auto check-out of unchanged files upon re-import, performing rever unchanged automatically. Closes #2618.

This commit is contained in:
Harald Csaszar 2024-08-30 18:18:21 +02:00
parent cff6943c3a
commit 4038bc9ba1
2 changed files with 31 additions and 2 deletions

View File

@ -61,6 +61,7 @@ using System.Linq;
using System.Reflection;
using System.Text;
using UnityEditor;
using UnityEditor.VersionControl;
using UnityEngine;
using CompatibilityProblemInfo = Spine.Unity.SkeletonDataCompatibility.CompatibilityProblemInfo;
@ -218,7 +219,7 @@ namespace Spine.Unity.Editor {
} else {
// On a "Reimport All" the order of imports can be wrong, thus LoadAssetAtPath() above could return null.
// as a workaround, we provide a fallback reader.
input = File.Open(skeletonDataPath, FileMode.Open, FileAccess.Read);
input = File.Open(skeletonDataPath, System.IO.FileMode.Open, FileAccess.Read);
}
binary.ReadSkeletonData(input);
} finally {
@ -493,6 +494,8 @@ namespace Spine.Unity.Editor {
}
}
}
RevertUnchangedOnPerforce(atlasPaths, skeletonPaths, newAtlases);
}
static void AddDependentAtlasIfImageChanged (List<string> atlasPaths, List<string> imagePaths) {
@ -526,6 +529,32 @@ namespace Spine.Unity.Editor {
}
}
/// <summary>Prevents automatic check-out of unchanged, identically re-created assets (e.g. when re-imported)
/// when using Perforce VCS.</summary>
static void RevertUnchangedOnPerforce (List<string> atlasPaths, List<PathAndProblemInfo> skeletonPaths, List<AtlasAssetBase> newAtlases) {
Plugin versionControl = Provider.GetActivePlugin();
if (versionControl != null && versionControl.name == "Perforce") {
AssetList assets = new AssetList();
foreach (string atlasPath in atlasPaths) {
assets.Add(Provider.GetAssetByPath(atlasPath));
}
foreach (PathAndProblemInfo skeletonPathInfo in skeletonPaths) {
if (skeletonPathInfo.compatibilityProblems == null)
assets.Add(Provider.GetAssetByPath(skeletonPathInfo.path));
}
foreach (AtlasAssetBase atlas in newAtlases) {
if (atlas != null)
assets.Add(Provider.GetAssetByPath(AssetDatabase.GetAssetPath(atlas)));
foreach (Material atlasMaterial in atlas.Materials) {
if (atlasMaterial != null)
assets.Add(Provider.GetAssetByPath(AssetDatabase.GetAssetPath(atlasMaterial)));
}
}
Provider.Revert(assets, RevertMode.Unchanged);
}
}
static void ReloadSkeletonData (string skeletonJSONPath, CompatibilityProblemInfo compatibilityProblemInfo) {
string dir = Path.GetDirectoryName(skeletonJSONPath).Replace('\\', '/');
TextAsset textAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonJSONPath);

View File

@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-unity",
"displayName": "spine-unity Runtime",
"description": "This plugin provides the spine-unity runtime core.",
"version": "4.2.82",
"version": "4.2.83",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",