Merge branch '3.8' into 3.9-beta

This commit is contained in:
badlogic 2019-10-31 17:10:50 +01:00
commit 114dd18c46
14 changed files with 64 additions and 27 deletions

View File

@ -1392,6 +1392,7 @@ declare module spine.webgl {
private texture;
private boundUnit;
private useMipMaps;
static DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL: boolean;
constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, image: HTMLImageElement, useMipMaps?: boolean);
setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
static validateMagFilter(magFilter: TextureFilter): TextureFilter.Nearest | TextureFilter.Linear | TextureFilter.Linear;

View File

@ -8521,6 +8521,8 @@ var spine;
this.texture = this.context.gl.createTexture();
}
this.bind();
if (GLTexture.DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL)
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._image);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, useMipMaps ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
@ -8550,6 +8552,7 @@ var spine;
var gl = this.context.gl;
gl.deleteTexture(this.texture);
};
GLTexture.DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL = false;
return GLTexture;
}(spine.Texture));
webgl.GLTexture = GLTexture;

File diff suppressed because one or more lines are too long

View File

@ -1361,6 +1361,7 @@ declare module spine.webgl {
private texture;
private boundUnit;
private useMipMaps;
static DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL: boolean;
constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, image: HTMLImageElement, useMipMaps?: boolean);
setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
static validateMagFilter(magFilter: TextureFilter): TextureFilter.Nearest | TextureFilter.Linear | TextureFilter.Linear;

View File

@ -8253,6 +8253,8 @@ var spine;
this.texture = this.context.gl.createTexture();
}
this.bind();
if (GLTexture.DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL)
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._image);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, useMipMaps ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
@ -8282,6 +8284,7 @@ var spine;
var gl = this.context.gl;
gl.deleteTexture(this.texture);
};
GLTexture.DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL = false;
return GLTexture;
}(spine.Texture));
webgl.GLTexture = GLTexture;

File diff suppressed because one or more lines are too long

View File

@ -1361,6 +1361,7 @@ declare module spine.webgl {
private texture;
private boundUnit;
private useMipMaps;
static DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL: boolean;
constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, image: HTMLImageElement, useMipMaps?: boolean);
setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
static validateMagFilter(magFilter: TextureFilter): TextureFilter.Nearest | TextureFilter.Linear | TextureFilter.Linear;

View File

@ -8253,6 +8253,8 @@ var spine;
this.texture = this.context.gl.createTexture();
}
this.bind();
if (GLTexture.DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL)
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._image);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, useMipMaps ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
@ -8282,6 +8284,7 @@ var spine;
var gl = this.context.gl;
gl.deleteTexture(this.texture);
};
GLTexture.DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL = false;
return GLTexture;
}(spine.Texture));
webgl.GLTexture = GLTexture;

File diff suppressed because one or more lines are too long

View File

@ -34,6 +34,8 @@ module spine.webgl {
private boundUnit = 0;
private useMipMaps = false;
public static DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL = false;
constructor (context: ManagedWebGLRenderingContext | WebGLRenderingContext, image: HTMLImageElement, useMipMaps: boolean = false) {
super(image);
this.context = context instanceof ManagedWebGLRenderingContext? context : new ManagedWebGLRenderingContext(context);
@ -75,6 +77,7 @@ module spine.webgl {
this.texture = this.context.gl.createTexture();
}
this.bind();
if (GLTexture.DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL) gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._image);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, useMipMaps ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);

View File

@ -143,7 +143,7 @@ namespace Spine.Unity.Editor {
attachmentType = (AttachmentType)System.Enum.Parse(typeof(AttachmentType), typeString, true);
} catch (System.ArgumentException e) {
// For more info, visit: http://esotericsoftware.com/forum/Spine-editor-and-runtime-version-management-6534
Debug.LogWarning(string.Format("Unidentified Attachment type: \"{0}\". Skeleton may have been exported from an incompatible Spine version.", typeString));
Debug.LogWarning(string.Format("Unidentified Attachment type: \"{0}\". Skeleton may have been exported from an incompatible Spine version.", typeString), spineJson);
throw e;
}
@ -309,7 +309,7 @@ namespace Spine.Unity.Editor {
continue;
}
string dir = Path.GetDirectoryName(skeletonPath);
string dir = Path.GetDirectoryName(skeletonPath).Replace('\\', '/');
#if SPINE_TK2D
IngestSpineProject(loadedAsset, null);
@ -353,7 +353,7 @@ namespace Spine.Unity.Editor {
}
static void ReloadSkeletonData (string skeletonJSONPath, CompatibilityProblemInfo compatibilityProblemInfo) {
string dir = Path.GetDirectoryName(skeletonJSONPath);
string dir = Path.GetDirectoryName(skeletonJSONPath).Replace('\\', '/');
TextAsset textAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonJSONPath);
DirectoryInfo dirInfo = new DirectoryInfo(dir);
FileInfo[] files = dirInfo.GetFiles("*.asset");
@ -437,7 +437,7 @@ namespace Spine.Unity.Editor {
}
string primaryName = Path.GetFileNameWithoutExtension(atlasText.name).Replace(".atlas", "");
string assetPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(atlasText));
string assetPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(atlasText)).Replace('\\', '/');
string atlasPath = assetPath + "/" + primaryName + AtlasSuffix + ".asset";
@ -515,9 +515,9 @@ namespace Spine.Unity.Editor {
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));
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), atlasAsset);
else
Debug.Log(string.Format("{0} :: Imported with {1} material", atlasAsset.name, atlasAsset.materials.Length));
Debug.Log(string.Format("{0} :: Imported with {1} material", atlasAsset.name, atlasAsset.materials.Length), atlasAsset);
// Iterate regions and bake marked.
Atlas atlas = atlasAsset.GetAtlas();
@ -525,7 +525,7 @@ namespace Spine.Unity.Editor {
FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.NonPublic);
var regions = (List<AtlasRegion>)field.GetValue(atlas);
string atlasAssetPath = AssetDatabase.GetAssetPath(atlasAsset);
string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath);
string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath).Replace('\\', '/');
string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name);
bool hasBakedRegions = false;
@ -552,7 +552,7 @@ namespace Spine.Unity.Editor {
static bool SetDefaultTextureSettings (string texturePath, SpineAtlasAsset atlasAsset) {
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));
Debug.LogWarning(string.Format("{0}: Texture asset \"{1}\" not found. Skipping. Please check your atlas file for renamed files.", atlasAsset.name, texturePath), atlasAsset);
return false;
}
@ -573,7 +573,7 @@ namespace Spine.Unity.Editor {
#region Import SkeletonData (json or binary)
internal static string GetSkeletonDataAssetFilePath(TextAsset spineJson) {
string primaryName = Path.GetFileNameWithoutExtension(spineJson.name);
string assetPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(spineJson));
string assetPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(spineJson)).Replace('\\', '/');
return assetPath + "/" + primaryName + SkeletonDataSuffix + ".asset";
}
@ -656,7 +656,7 @@ namespace Spine.Unity.Editor {
#region Spine Skeleton Data File Validation
public static bool CheckForValidSkeletonData (string skeletonJSONPath) {
string dir = Path.GetDirectoryName(skeletonJSONPath);
string dir = Path.GetDirectoryName(skeletonJSONPath).Replace('\\', '/');
TextAsset textAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonJSONPath);
DirectoryInfo dirInfo = new DirectoryInfo(dir);
FileInfo[] files = dirInfo.GetFiles("*.asset");
@ -694,7 +694,7 @@ namespace Spine.Unity.Editor {
switch (result) {
case -1:
//Debug.Log("Select Atlas");
AtlasAssetBase selectedAtlas = BrowseAtlasDialog(Path.GetDirectoryName(skeletonPath));
AtlasAssetBase selectedAtlas = BrowseAtlasDialog(Path.GetDirectoryName(skeletonPath).Replace('\\', '/'));
if (selectedAtlas != null) {
localAtlases.Clear();
localAtlases.Add(selectedAtlas);
@ -706,7 +706,8 @@ namespace Spine.Unity.Editor {
}
break;
case 0: // Resolve AtlasAssets...
var atlasList = MultiAtlasDialog(requiredPaths, Path.GetDirectoryName(skeletonPath), Path.GetFileNameWithoutExtension(skeletonPath));
var atlasList = MultiAtlasDialog(requiredPaths, Path.GetDirectoryName(skeletonPath).Replace('\\', '/'),
Path.GetFileNameWithoutExtension(skeletonPath));
if (atlasList != null)
AssetUtility.IngestSpineProject(AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonPath), atlasList.ToArray());
@ -905,7 +906,7 @@ namespace Spine.Unity.Editor {
}
if (data == null) {
Debug.LogWarning("InstantiateSkeletonAnimation tried to instantiate a skeleton from an invalid SkeletonDataAsset.");
Debug.LogWarning("InstantiateSkeletonAnimation tried to instantiate a skeleton from an invalid SkeletonDataAsset.", skeletonDataAsset);
return null;
}
@ -920,7 +921,7 @@ namespace Spine.Unity.Editor {
newSkeletonAnimation.Initialize(false);
} catch (System.Exception e) {
if (destroyInvalid) {
Debug.LogWarning("Editor-instantiated SkeletonAnimation threw an Exception. Destroying GameObject to prevent orphaned GameObject.");
Debug.LogWarning("Editor-instantiated SkeletonAnimation threw an Exception. Destroying GameObject to prevent orphaned GameObject.", skeletonDataAsset);
GameObject.DestroyImmediate(go);
}
throw e;
@ -982,7 +983,7 @@ namespace Spine.Unity.Editor {
}
if (data == null) {
Debug.LogWarning("InstantiateSkeletonMecanim tried to instantiate a skeleton from an invalid SkeletonDataAsset.");
Debug.LogWarning("InstantiateSkeletonMecanim tried to instantiate a skeleton from an invalid SkeletonDataAsset.", skeletonDataAsset);
return null;
}
@ -991,7 +992,7 @@ namespace Spine.Unity.Editor {
if (skeletonDataAsset.controller == null) {
SkeletonBaker.GenerateMecanimAnimationClips(skeletonDataAsset);
Debug.Log(string.Format("Mecanim controller was automatically generated and assigned for {0}", skeletonDataAsset.name));
Debug.Log(string.Format("Mecanim controller was automatically generated and assigned for {0}", skeletonDataAsset.name), skeletonDataAsset);
}
go.GetComponent<Animator>().runtimeAnimatorController = skeletonDataAsset.controller;
@ -1005,7 +1006,7 @@ namespace Spine.Unity.Editor {
newSkeletonMecanim.Initialize(false);
} catch (System.Exception e) {
if (destroyInvalid) {
Debug.LogWarning("Editor-instantiated SkeletonAnimation threw an Exception. Destroying GameObject to prevent orphaned GameObject.");
Debug.LogWarning("Editor-instantiated SkeletonAnimation threw an Exception. Destroying GameObject to prevent orphaned GameObject.", skeletonDataAsset);
GameObject.DestroyImmediate(go);
}
throw e;

View File

@ -106,12 +106,12 @@ namespace Spine.Unity.Editor {
string[] assets = AssetDatabase.FindAssets("t:script SpineEditorUtilities");
string assetPath = AssetDatabase.GUIDToAssetPath(assets[0]);
editorPath = Path.GetDirectoryName(assetPath).Replace("\\", "/");
editorPath = Path.GetDirectoryName(assetPath).Replace('\\', '/');
assets = AssetDatabase.FindAssets("t:texture icon-subMeshRenderer");
if (assets.Length > 0) {
assetPath = AssetDatabase.GUIDToAssetPath(assets[0]);
editorGUIPath = Path.GetDirectoryName(assetPath).Replace("\\", "/");
editorGUIPath = Path.GetDirectoryName(assetPath).Replace('\\', '/');
}
else {
editorGUIPath = editorPath.Replace("/Utility", "/GUI");

View File

@ -186,7 +186,7 @@ namespace Spine.Unity.Editor {
}
if (outputPath == "") {
outputPath = System.IO.Path.GetDirectoryName(AssetDatabase.GetAssetPath(skeletonDataAsset)) + "/Baked";
outputPath = System.IO.Path.GetDirectoryName(AssetDatabase.GetAssetPath(skeletonDataAsset)).Replace('\\', '/') + "/Baked";
System.IO.Directory.CreateDirectory(outputPath);
}
@ -1424,7 +1424,7 @@ namespace Spine.Unity.Editor {
atlasAsset.GetAtlas(); // Initializes atlasAsset.
string atlasAssetPath = AssetDatabase.GetAssetPath(atlasAsset);
string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath);
string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath).Replace('\\', '/');
string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name);
string bakedPrefabPath = Path.Combine(bakedDirPath, AssetUtility.GetPathSafeName(region.name) + ".prefab").Replace("\\", "/");

View File

@ -128,12 +128,30 @@ namespace Spine.Unity {
public delegate void SkeletonUtilityDelegate ();
public event SkeletonUtilityDelegate OnReset;
public Transform boneRoot;
/// <summary>
/// If true, <see cref="Skeleton.ScaleX"/> and <see cref="Skeleton.ScaleY"/> are followed
/// by 180 degree rotation. If false, negative Transform scale is used.
/// Note that using negative scale is consistent with previous behaviour (hence the default),
/// however causes serious problems with rigidbodies and physics. Therefore, it is recommended to
/// enable this parameter where possible. When creating hinge chains for a chain of skeleton bones
/// via <see cref="SkeletonUtilityBone"/>, it is mandatory to have <c>flipBy180DegreeRotation</c> enabled.
/// </summary>
public bool flipBy180DegreeRotation = false;
void Update () {
var skeleton = skeletonRenderer.skeleton;
if (skeleton != null && boneRoot != null) {
boneRoot.localScale = new Vector3(skeleton.ScaleX, skeleton.ScaleY, 1f);
}
if (flipBy180DegreeRotation) {
boneRoot.localScale = new Vector3(Mathf.Abs(skeleton.ScaleX), Mathf.Abs(skeleton.ScaleY), 1f);
boneRoot.eulerAngles = new Vector3(skeleton.ScaleY > 0 ? 0 : 180,
skeleton.ScaleX > 0 ? 0 : 180,
0);
}
else {
boneRoot.localScale = new Vector3(skeleton.ScaleX, skeleton.ScaleY, 1f);
}
}
}
[HideInInspector] public SkeletonRenderer skeletonRenderer;
@ -233,7 +251,10 @@ namespace Spine.Unity {
var boneComponents = this.boneComponents;
for (int i = 0, n = boneComponents.Count; i < n; i++) {
var b = boneComponents[i];
if (b.bone == null) continue;
if (b.bone == null) {
b.DoUpdate(SkeletonUtilityBone.UpdatePhase.Local);
if (b.bone == null) continue;
}
hasOverrideBones |= (b.mode == SkeletonUtilityBone.Mode.Override);
hasConstraints |= constraintTargets.Contains(b.bone);
}