mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-11 09:38:44 +08:00
Merge branch '3.6' into 3.7-beta
This commit is contained in:
commit
a18491691a
@ -139,8 +139,9 @@ namespace Spine {
|
||||
bool finished = UpdateMixingFrom(from, delta);
|
||||
|
||||
// Require mixTime > 0 to ensure the mixing from entry was applied at least once.
|
||||
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
|
||||
if (from.totalAlpha == 0) {
|
||||
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
|
||||
// Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame).
|
||||
if (from.totalAlpha == 0 || to.mixDuration == 0) {
|
||||
to.mixingFrom = from.mixingFrom;
|
||||
to.interruptAlpha = from.interruptAlpha;
|
||||
queue.End(from);
|
||||
@ -707,10 +708,13 @@ namespace Spine {
|
||||
} else {
|
||||
for (int ii = mixingToLast; ii >= 0; ii--) {
|
||||
var entry = mixingTo[ii];
|
||||
if (entry.mixDuration > 0 && !entry.HasTimeline(id)) {
|
||||
timelineDataItems[i] = AnimationState.DipMix;
|
||||
timelineDipMixItems[i] = entry;
|
||||
goto outer; // continue outer;
|
||||
if (!entry.HasTimeline(id)) {
|
||||
if (entry.mixDuration > 0) {
|
||||
timelineDataItems[i] = AnimationState.DipMix;
|
||||
timelineDipMixItems[i] = entry;
|
||||
goto outer; // continue outer;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
timelineDataItems[i] = AnimationState.Dip;
|
||||
|
||||
@ -258,7 +258,7 @@ namespace Spine {
|
||||
return clipped;
|
||||
}
|
||||
|
||||
public static void MakeClockwise (ExposedList<float> polygon) {
|
||||
static void MakeClockwise (ExposedList<float> polygon) {
|
||||
float[] vertices = polygon.Items;
|
||||
int verticeslength = polygon.Count;
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
using System;
|
||||
|
||||
namespace Spine {
|
||||
public class Triangulator {
|
||||
internal class Triangulator {
|
||||
private readonly ExposedList<ExposedList<float>> convexPolygons = new ExposedList<ExposedList<float>>();
|
||||
private readonly ExposedList<ExposedList<int>> convexPolygonsIndices = new ExposedList<ExposedList<int>>();
|
||||
|
||||
|
||||
@ -144,7 +144,8 @@ public class AnimationState {
|
||||
|
||||
// Require mixTime > 0 to ensure the mixing from entry was applied at least once.
|
||||
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
|
||||
if (from.totalAlpha == 0) {
|
||||
// Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame).
|
||||
if (from.totalAlpha == 0 || to.mixDuration == 0) {
|
||||
to.mixingFrom = from.mixingFrom;
|
||||
to.interruptAlpha = from.interruptAlpha;
|
||||
queue.end(from);
|
||||
|
||||
@ -128,6 +128,7 @@ public class SkeletonViewer extends ApplicationAdapter {
|
||||
Gdx.files.internal(Gdx.app.getPreferences("spine-skeletonviewer").getString("lastFile", "spineboy/spineboy.json")));
|
||||
|
||||
ui.loadPrefs();
|
||||
ui.prefsLoaded = true;
|
||||
}
|
||||
|
||||
void loadSkeleton (final FileHandle skeletonFile) {
|
||||
@ -142,7 +143,8 @@ public class SkeletonViewer extends ApplicationAdapter {
|
||||
pixmap.dispose();
|
||||
|
||||
String atlasFileName = skeletonFile.nameWithoutExtension();
|
||||
if (atlasFileName.endsWith(".json")) atlasFileName = new FileHandle(atlasFileName).nameWithoutExtension();
|
||||
if (atlasFileName.endsWith(".json") || atlasFileName.endsWith(".skel"))
|
||||
atlasFileName = atlasFileName.substring(0, atlasFileName.length() - 5);
|
||||
FileHandle atlasFile = skeletonFile.sibling(atlasFileName + ".atlas");
|
||||
if (!atlasFile.exists()) {
|
||||
if (atlasFileName.endsWith("-pro") || atlasFileName.endsWith("-ess"))
|
||||
@ -380,6 +382,8 @@ public class SkeletonViewer extends ApplicationAdapter {
|
||||
}
|
||||
|
||||
class UI {
|
||||
boolean prefsLoaded;
|
||||
|
||||
Stage stage = new Stage(new ScreenViewport());
|
||||
com.badlogic.gdx.scenes.scene2d.ui.Skin skin = new com.badlogic.gdx.scenes.scene2d.ui.Skin(
|
||||
Gdx.files.internal("skin/skin.json"));
|
||||
@ -436,7 +440,6 @@ public class SkeletonViewer extends ApplicationAdapter {
|
||||
|
||||
Label statusLabel = new Label("", skin);
|
||||
WidgetGroup toasts = new WidgetGroup();
|
||||
boolean prefsLoaded;
|
||||
|
||||
UI () {
|
||||
initialize();
|
||||
@ -706,6 +709,16 @@ public class SkeletonViewer extends ApplicationAdapter {
|
||||
}
|
||||
});
|
||||
|
||||
InputListener scrollFocusListener = new InputListener() {
|
||||
public void enter (InputEvent event, float x, float y, int pointer, Actor fromActor) {
|
||||
if (pointer == -1) stage.setScrollFocus(event.getListenerActor());
|
||||
}
|
||||
|
||||
public void exit (InputEvent event, float x, float y, int pointer, Actor toActor) {
|
||||
if (pointer == -1 && stage.getScrollFocus() == event.getListenerActor()) stage.setScrollFocus(null);
|
||||
}
|
||||
};
|
||||
|
||||
animationList.addListener(new ChangeListener() {
|
||||
public void changed (ChangeEvent event, Actor actor) {
|
||||
if (state != null) {
|
||||
@ -717,6 +730,7 @@ public class SkeletonViewer extends ApplicationAdapter {
|
||||
}
|
||||
}
|
||||
});
|
||||
animationScroll.addListener(scrollFocusListener);
|
||||
|
||||
loopCheckbox.addListener(new ChangeListener() {
|
||||
public void changed (ChangeEvent event, Actor actor) {
|
||||
@ -736,6 +750,7 @@ public class SkeletonViewer extends ApplicationAdapter {
|
||||
}
|
||||
}
|
||||
});
|
||||
skinScroll.addListener(scrollFocusListener);
|
||||
|
||||
ChangeListener trackButtonListener = new ChangeListener() {
|
||||
public void changed (ChangeEvent event, Actor actor) {
|
||||
@ -909,7 +924,6 @@ public class SkeletonViewer extends ApplicationAdapter {
|
||||
scaleSlider.setValue(prefs.getFloat("scale", 1));
|
||||
animationList.setSelected(prefs.getString("animationName", null));
|
||||
skinList.setSelected(prefs.getString("skinName", null));
|
||||
prefsLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1020,13 +1020,18 @@ namespace Spine.Unity.Editor {
|
||||
pageFiles.Add(atlasLines[i + 1].Trim());
|
||||
}
|
||||
|
||||
atlasAsset.materials = new Material[pageFiles.Count];
|
||||
var populatingMaterials = new List<Material>(pageFiles.Count);//atlasAsset.materials = new Material[pageFiles.Count];
|
||||
|
||||
for (int i = 0; i < pageFiles.Count; i++) {
|
||||
string texturePath = assetPath + "/" + pageFiles[i];
|
||||
Texture2D texture = (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D));
|
||||
|
||||
TextureImporter texImporter = (TextureImporter)TextureImporter.GetAtPath(texturePath);
|
||||
if (texImporter == null) {
|
||||
Debug.LogWarning(string.Format("{0} ::: Texture asset \"{1}\" not found. Skipping. Please check your atlas file for renamed files.", atlasAsset.name, texturePath));
|
||||
continue;
|
||||
}
|
||||
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
texImporter.textureCompression = TextureImporterCompression.Uncompressed;
|
||||
texImporter.alphaSource = TextureImporterAlphaSource.FromInput;
|
||||
@ -1039,7 +1044,6 @@ namespace Spine.Unity.Editor {
|
||||
texImporter.spriteImportMode = SpriteImportMode.None;
|
||||
texImporter.maxTextureSize = 2048;
|
||||
|
||||
|
||||
EditorUtility.SetDirty(texImporter);
|
||||
AssetDatabase.ImportAsset(texturePath);
|
||||
AssetDatabase.SaveAssets();
|
||||
@ -1064,9 +1068,11 @@ namespace Spine.Unity.Editor {
|
||||
EditorUtility.SetDirty(mat);
|
||||
AssetDatabase.SaveAssets();
|
||||
|
||||
atlasAsset.materials[i] = mat;
|
||||
populatingMaterials.Add(mat); //atlasAsset.materials[i] = mat;
|
||||
}
|
||||
|
||||
atlasAsset.materials = populatingMaterials.ToArray();
|
||||
|
||||
for (int i = 0; i < vestigialMaterials.Count; i++)
|
||||
AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(vestigialMaterials[i]));
|
||||
|
||||
@ -1078,6 +1084,11 @@ namespace Spine.Unity.Editor {
|
||||
EditorUtility.SetDirty(atlasAsset);
|
||||
AssetDatabase.SaveAssets();
|
||||
|
||||
if (pageFiles.Count != atlasAsset.materials.Length)
|
||||
Debug.LogWarning(string.Format("{0} ::: Not all atlas pages were imported. If you rename your image files, please make sure you also edit the filenames specified in the atlas file.", atlasAsset.name));
|
||||
else
|
||||
Debug.Log(string.Format("{0} ::: Imported with {1} material", atlasAsset.name, atlasAsset.materials.Length));
|
||||
|
||||
// Iterate regions and bake marked.
|
||||
Atlas atlas = atlasAsset.GetAtlas();
|
||||
FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.NonPublic);
|
||||
|
||||
@ -133,7 +133,7 @@ namespace Spine.Unity.Modules {
|
||||
}
|
||||
|
||||
Applied = false;
|
||||
skeletonRenderer.LateUpdate();
|
||||
if (skeletonRenderer.valid) skeletonRenderer.LateUpdate();
|
||||
}
|
||||
|
||||
public void GetTexture () {
|
||||
|
||||
@ -185,6 +185,20 @@ namespace Spine.Unity {
|
||||
bone.WorldToLocal(worldPosition.x, worldPosition.y, out o.x, out o.y);
|
||||
return o;
|
||||
}
|
||||
|
||||
/// <summary>Sets the skeleton-space position of a bone.</summary>
|
||||
/// <returns>The local position in its parent bone space, or in skeleton space if it is the root bone.</returns>
|
||||
public static Vector2 SetPositionSkeletonSpace (this Bone bone, Vector2 skeletonSpacePosition) {
|
||||
if (bone.parent == null) { // root bone
|
||||
bone.SetPosition(skeletonSpacePosition);
|
||||
return skeletonSpacePosition;
|
||||
} else {
|
||||
var parent = bone.parent;
|
||||
Vector2 parentLocal = parent.WorldToLocal(skeletonSpacePosition);
|
||||
bone.SetPosition(parentLocal);
|
||||
return parentLocal;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Attachments
|
||||
|
||||
@ -61,13 +61,14 @@ namespace Spine.Unity {
|
||||
public bool useClipping = true;
|
||||
public bool immutableTriangles = false;
|
||||
public bool pmaVertexColors = true;
|
||||
/// <summary>Clears the state when this component or its GameObject is disabled. This prevents previous state from being retained when it is enabled again. When pooling your skeleton, setting this to true can be helpful.</summary>
|
||||
public bool clearStateOnDisable = false;
|
||||
public bool tintBlack = false;
|
||||
public bool singleSubmesh = false;
|
||||
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("calculateNormals")]
|
||||
public bool addNormals;
|
||||
public bool calculateTangents;
|
||||
public bool addNormals = false;
|
||||
public bool calculateTangents = false;
|
||||
|
||||
public bool logErrors = false;
|
||||
|
||||
@ -134,6 +135,18 @@ namespace Spine.Unity {
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/// <summary>Applies MeshGenerator settings to the SkeletonRenderer and its internal MeshGenerator.</summary>
|
||||
public void SetMeshSettings (MeshGenerator.Settings settings) {
|
||||
this.calculateTangents = settings.calculateTangents;
|
||||
this.immutableTriangles = settings.immutableTriangles;
|
||||
this.pmaVertexColors = settings.pmaVertexColors;
|
||||
this.tintBlack = settings.tintBlack;
|
||||
this.useClipping = settings.useClipping;
|
||||
this.zSpacing = settings.zSpacing;
|
||||
|
||||
this.meshGenerator.settings = settings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public virtual void Awake () {
|
||||
@ -147,6 +160,7 @@ namespace Spine.Unity {
|
||||
|
||||
void OnDestroy () {
|
||||
rendererBuffers.Dispose();
|
||||
valid = false;
|
||||
}
|
||||
|
||||
public virtual void ClearState () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user