Merge branch '4.0' into 4.1-beta

This commit is contained in:
badlogic 2022-04-21 14:05:53 +02:00
commit 83df6b7316
8 changed files with 44 additions and 16 deletions

View File

@ -56,8 +56,8 @@ You can include a module in your project via a `<script>` tag from the [unpkg](h
<script src="https://unpkg.com/@esotericsoftware/spine-player@4.0.*/dist/iife/spine-player.js">
<link rel="stylesheet" href="https://unpkg.com/@esotericsoftware/spine-player@4.0.*/dist/spine-player.css">
// spine-ts WebGL
<script src="https://unpkg.com/@esotericsoftware/spine-threejs@4.0.*/dist/iife/spine-webgl.js">
// spine-ts ThreeJS
<script src="https://unpkg.com/@esotericsoftware/spine-threejs@4.0.*/dist/iife/spine-threejs.js">
```
We also provide `js.map` source maps. They will be automatically fetched from unpkg when debugging code of a spine-module in Chrome, Firefox, or Safari, mapping the JavaScript code back to its original TypeScript sources.
@ -113,4 +113,4 @@ The final command `npm run dev` will start a local web server at http://127.0.0.
You can then open Visual Studio Code to inspect, edit, and debug the source code. We also supply launch configurations to start examples and demos in debug mode, so you can debug them right inside Visual Studio code.
To build the artifacts as they are published to NPM, run `npm run build`.
To build the artifacts as they are published to NPM, run `npm run build`.

View File

@ -65,7 +65,12 @@ void SSpineWidget::SetData(USpineWidget *Widget) {
skeleton->setToSetupPose();
skeleton->updateWorldTransform();
Vector<float> scratchBuffer;
skeleton->getBounds(this->boundsMin.X, this->boundsMin.Y, this->boundsSize.X, this->boundsSize.Y, scratchBuffer);
float x, y, w, h;
skeleton->getBounds(x, y, w, h, scratchBuffer);
boundsMin.X = x;
boundsMin.Y = y;
boundsSize.X = w;
boundsSize.Y = h;
}
}

View File

@ -154,7 +154,7 @@ namespace Spine.Unity.Editor {
void Clear () {
preview.Clear();
targetSkeletonDataAsset.Clear();
SpineEditorUtilities.ClearSkeletonDataAsset(targetSkeletonDataAsset);
targetSkeletonData = null;
}

View File

@ -493,7 +493,7 @@ namespace Spine.Unity.Editor {
}
Debug.LogFormat("Changes to '{0}' or atlas detected. Clearing SkeletonDataAsset: {1}", skeletonJSONPath, localPath);
skeletonDataAsset.Clear();
SpineEditorUtilities.ClearSkeletonDataAsset(skeletonDataAsset);
string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(skeletonDataAsset));
string lastHash = EditorPrefs.GetString(guid + "_hash");
@ -978,7 +978,7 @@ namespace Spine.Unity.Editor {
AssetDatabase.CreateAsset(skeletonDataAsset, filePath);
} else {
skeletonDataAsset.atlasAssets = atlasAssets;
skeletonDataAsset.Clear();
SpineEditorUtilities.ClearSkeletonDataAsset(skeletonDataAsset);
}
var skeletonData = skeletonDataAsset.GetSkeletonData(true);
if (skeletonData != null)

View File

@ -96,7 +96,7 @@ namespace Spine.Unity.Editor {
}
}
skeletonDataAsset.Clear();
SpineEditorUtilities.ClearSkeletonDataAsset(skeletonDataAsset);
skeletonData = skeletonDataAsset.GetSkeletonData(true);
if (anyMaterialsChanged)
ReloadSceneSkeletons(skeletonDataAsset);
@ -164,7 +164,7 @@ namespace Spine.Unity.Editor {
var skinEntries = new List<Skin.SkinEntry>();
skeletonDataAsset.Clear();
SpineEditorUtilities.ClearSkeletonDataAsset(skeletonDataAsset);
skeletonDataAsset.isUpgradingBlendModeMaterials = true;
SkeletonData skeletonData = skeletonDataAsset.GetSkeletonData(true);

View File

@ -91,8 +91,7 @@ namespace Spine.Unity.Editor {
}
foreach (var skeletonDataAsset in skeletonDataAssetsToReload) {
skeletonDataAsset.Clear();
skeletonDataAsset.GetSkeletonData(true);
ReloadSkeletonDataAsset(skeletonDataAsset, false);
}
foreach (var skeletonRenderer in activeSkeletonRenderers)
@ -119,14 +118,24 @@ namespace Spine.Unity.Editor {
}
}
public static void ClearAnimationReferenceAssets (SkeletonDataAsset skeletonDataAsset) {
ForEachAnimationReferenceAsset(skeletonDataAsset, (referenceAsset) => referenceAsset.Clear());
}
public static void ReloadAnimationReferenceAssets (SkeletonDataAsset skeletonDataAsset) {
ForEachAnimationReferenceAsset(skeletonDataAsset, (referenceAsset) => referenceAsset.Initialize());
}
private static void ForEachAnimationReferenceAsset (SkeletonDataAsset skeletonDataAsset,
System.Action<AnimationReferenceAsset> func) {
string[] guids = UnityEditor.AssetDatabase.FindAssets("t:AnimationReferenceAsset");
foreach (string guid in guids) {
string path = UnityEditor.AssetDatabase.GUIDToAssetPath(guid);
if (!string.IsNullOrEmpty(path)) {
var referenceAsset = UnityEditor.AssetDatabase.LoadAssetAtPath<AnimationReferenceAsset>(path);
if (referenceAsset.SkeletonDataAsset == skeletonDataAsset)
referenceAsset.Initialize();
func(referenceAsset);
}
}
}

View File

@ -266,14 +266,23 @@ namespace Spine.Unity.Editor {
ReinitializeComponent(component);
}
public static void ReloadSkeletonDataAsset (SkeletonDataAsset skeletonDataAsset) {
if (skeletonDataAsset != null) {
public static void ClearSkeletonDataAsset (SkeletonDataAsset skeletonDataAsset) {
skeletonDataAsset.Clear();
DataReloadHandler.ClearAnimationReferenceAssets(skeletonDataAsset);
}
public static void ReloadSkeletonDataAsset (SkeletonDataAsset skeletonDataAsset, bool clearAtlasAssets = true) {
if (skeletonDataAsset == null)
return;
if (clearAtlasAssets) {
foreach (AtlasAssetBase aa in skeletonDataAsset.atlasAssets) {
if (aa != null) aa.Clear();
}
skeletonDataAsset.Clear();
}
ClearSkeletonDataAsset(skeletonDataAsset);
skeletonDataAsset.GetSkeletonData(true);
DataReloadHandler.ReloadAnimationReferenceAssets(skeletonDataAsset);
}
public static void ReinitializeComponent (SkeletonRenderer component) {

View File

@ -48,11 +48,16 @@ namespace Spine.Unity {
if (animation == null)
Initialize();
#endif
return animation;
}
}
/// <summary>Clears the cached animation corresponding to a loaded SkeletonData object.
/// Use this to force a reload for the next time Animation is called.</summary>
public void Clear () {
animation = null;
}
public void Initialize () {
if (skeletonDataAsset == null) return;
SkeletonData skeletonData = skeletonDataAsset.GetSkeletonData(AnimationReferenceAsset.QuietSkeletonData);