Merge remote-tracking branch 'EsotericSoftware/3.6' into 3.6

This commit is contained in:
Stephen Gowen 2018-01-18 11:13:35 -05:00
commit 945db25c6f
9 changed files with 27 additions and 44 deletions

View File

@ -34,7 +34,7 @@ namespace Spine {
abstract public class Attachment { abstract public class Attachment {
public string Name { get; private set; } public string Name { get; private set; }
public Attachment (String name) { protected Attachment (string name) {
if (name == null) throw new ArgumentNullException("name", "name cannot be null"); if (name == null) throw new ArgumentNullException("name", "name cannot be null");
Name = name; Name = name;
} }
@ -43,4 +43,8 @@ namespace Spine {
return Name; return Name;
} }
} }
public interface IHasRendererObject {
object RendererObject { get; }
}
} }

View File

@ -32,7 +32,7 @@ using System;
namespace Spine { namespace Spine {
/// <summary>Attachment that displays a texture region using a mesh.</summary> /// <summary>Attachment that displays a texture region using a mesh.</summary>
public class MeshAttachment : VertexAttachment { public class MeshAttachment : VertexAttachment, IHasRendererObject {
internal float regionOffsetX, regionOffsetY, regionWidth, regionHeight, regionOriginalWidth, regionOriginalHeight; internal float regionOffsetX, regionOffsetY, regionWidth, regionHeight, regionOriginalWidth, regionOriginalHeight;
private MeshAttachment parentMesh; private MeshAttachment parentMesh;
internal float[] uvs, regionUVs; internal float[] uvs, regionUVs;
@ -53,7 +53,7 @@ namespace Spine {
public float A { get { return a; } set { a = value; } } public float A { get { return a; } set { a = value; } }
public string Path { get; set; } public string Path { get; set; }
public object RendererObject; //public Object RendererObject { get; set; } public object RendererObject { get; set; }
public float RegionU { get; set; } public float RegionU { get; set; }
public float RegionV { get; set; } public float RegionV { get; set; }
public float RegionU2 { get; set; } public float RegionU2 { get; set; }

View File

@ -32,7 +32,7 @@ using System;
namespace Spine { namespace Spine {
/// <summary>Attachment that displays a texture region.</summary> /// <summary>Attachment that displays a texture region.</summary>
public class RegionAttachment : Attachment { public class RegionAttachment : Attachment, IHasRendererObject {
public const int BLX = 0; public const int BLX = 0;
public const int BLY = 1; public const int BLY = 1;
public const int ULX = 2; public const int ULX = 2;
@ -61,7 +61,7 @@ namespace Spine {
public float A { get { return a; } set { a = value; } } public float A { get { return a; } set { a = value; } }
public string Path { get; set; } public string Path { get; set; }
public object RendererObject; //public object RendererObject { get; set; } public object RendererObject { get; set; }
public float RegionOffsetX { get { return regionOffsetX; } set { regionOffsetX = value; } } public float RegionOffsetX { get { return regionOffsetX; } set { regionOffsetX = value; } }
public float RegionOffsetY { get { return regionOffsetY; } set { regionOffsetY = value; } } // Pixels stripped from the bottom left, unrotated. public float RegionOffsetY { get { return regionOffsetY; } set { regionOffsetY = value; } } // Pixels stripped from the bottom left, unrotated.
public float RegionWidth { get { return regionWidth; } set { regionWidth = value; } } public float RegionWidth { get { return regionWidth; } set { regionWidth = value; } }

View File

@ -1,4 +1,4 @@
// //
// System.Collections.Generic.List // System.Collections.Generic.List
// //
// Authors: // Authors:

View File

@ -45,7 +45,7 @@ namespace Spine.Unity.Editor {
CreateAsset<SkeletonDataAsset>("New SkeletonData"); CreateAsset<SkeletonDataAsset>("New SkeletonData");
} }
static private void CreateAsset <T> (String name) where T : ScriptableObject { static void CreateAsset<T> (String name) where T : ScriptableObject {
var dir = "Assets/"; var dir = "Assets/";
var selected = Selection.activeObject; var selected = Selection.activeObject;
if (selected != null) { if (selected != null) {
@ -70,7 +70,7 @@ namespace Spine.Unity.Editor {
CreateSpineGameObject<SkeletonAnimation>("New SkeletonAnimation"); CreateSpineGameObject<SkeletonAnimation>("New SkeletonAnimation");
} }
static public void CreateSpineGameObject<T> (string name) where T : MonoBehaviour { static void CreateSpineGameObject<T> (string name) where T : MonoBehaviour {
var parentGameObject = Selection.activeObject as GameObject; var parentGameObject = Selection.activeObject as GameObject;
var parentTransform = parentGameObject == null ? null : parentGameObject.transform; var parentTransform = parentGameObject == null ? null : parentGameObject.transform;

View File

@ -625,7 +625,7 @@ namespace Spine.Unity.Editor {
public event Action<string> OnSkinChanged; public event Action<string> OnSkinChanged;
Texture previewTexture = new Texture(); Texture previewTexture;
PreviewRenderUtility previewRenderUtility; PreviewRenderUtility previewRenderUtility;
Camera PreviewUtilityCamera { Camera PreviewUtilityCamera {
get { get {

View File

@ -37,13 +37,9 @@ namespace Spine.Unity.Modules.AttachmentTools {
/// <summary> /// <summary>
/// Tries to get the region (image) of a renderable attachment. If the attachment is not renderable, it returns null.</summary> /// Tries to get the region (image) of a renderable attachment. If the attachment is not renderable, it returns null.</summary>
public static AtlasRegion GetRegion (this Attachment attachment) { public static AtlasRegion GetRegion (this Attachment attachment) {
var regionAttachment = attachment as RegionAttachment; var renderableAttachment = attachment as IHasRendererObject;
if (regionAttachment != null) if (renderableAttachment != null)
return regionAttachment.RendererObject as AtlasRegion; return renderableAttachment.RendererObject as AtlasRegion;
var meshAttachment = attachment as MeshAttachment;
if (meshAttachment != null)
return meshAttachment.RendererObject as AtlasRegion;
return null; return null;
} }
@ -418,7 +414,7 @@ namespace Spine.Unity.Modules.AttachmentTools {
var newAttachment = originalAttachment.GetClone(true); var newAttachment = originalAttachment.GetClone(true);
if (IsRenderable(newAttachment)) { if (IsRenderable(newAttachment)) {
var region = newAttachment.GetAtlasRegion(); var region = newAttachment.GetRegion();
int existingIndex; int existingIndex;
if (existingRegions.TryGetValue(region, out existingIndex)) { if (existingRegions.TryGetValue(region, out existingIndex)) {
regionIndexes.Add(existingIndex); // Store the region index for the eventual new attachment. regionIndexes.Add(existingIndex); // Store the region index for the eventual new attachment.
@ -503,7 +499,7 @@ namespace Spine.Unity.Modules.AttachmentTools {
var newAttachment = kvp.Value.GetClone(true); var newAttachment = kvp.Value.GetClone(true);
if (IsRenderable(newAttachment)) { if (IsRenderable(newAttachment)) {
var region = newAttachment.GetAtlasRegion(); var region = newAttachment.GetRegion();
int existingIndex; int existingIndex;
if (existingRegions.TryGetValue(region, out existingIndex)) { if (existingRegions.TryGetValue(region, out existingIndex)) {
regionIndexes.Add(existingIndex); // Store the region index for the eventual new attachment. regionIndexes.Add(existingIndex); // Store the region index for the eventual new attachment.
@ -627,7 +623,7 @@ namespace Spine.Unity.Modules.AttachmentTools {
} }
static bool IsRenderable (Attachment a) { static bool IsRenderable (Attachment a) {
return a is RegionAttachment || a is MeshAttachment; return a is IHasRendererObject;
} }
/// <summary> /// <summary>
@ -719,20 +715,6 @@ namespace Spine.Unity.Modules.AttachmentTools {
}; };
} }
/// <summary>
/// Tries to get the backing AtlasRegion of an attachment if it is renderable. Returns null for non-renderable attachments.</summary>
static AtlasRegion GetAtlasRegion (this Attachment a) {
var regionAttachment = a as RegionAttachment;
if (regionAttachment != null)
return (regionAttachment.RendererObject) as AtlasRegion;
var meshAttachment = a as MeshAttachment;
if (meshAttachment != null)
return (meshAttachment.RendererObject) as AtlasRegion;
return null;
}
/// <summary> /// <summary>
/// Convenience method for getting the main texture of the material of the page of the region.</summary> /// Convenience method for getting the main texture of the material of the page of the region.</summary>
static Texture2D GetMainTexture (this AtlasRegion region) { static Texture2D GetMainTexture (this AtlasRegion region) {

View File

@ -212,13 +212,10 @@ namespace Spine.Unity {
#region Attachments #region Attachments
public static Material GetMaterial (this Attachment a) { public static Material GetMaterial (this Attachment a) {
object rendererObject = null; object rendererObject = null;
var regionAttachment = a as RegionAttachment; var renderableAttachment = a as IHasRendererObject;
if (regionAttachment != null) if (renderableAttachment != null) {
rendererObject = regionAttachment.RendererObject; rendererObject = renderableAttachment.RendererObject;
}
var meshAttachment = a as MeshAttachment;
if (meshAttachment != null)
rendererObject = meshAttachment.RendererObject;
if (rendererObject == null) if (rendererObject == null)
return null; return null;
@ -297,7 +294,7 @@ namespace Spine {
} }
public static bool IsRenderable (this Attachment a) { public static bool IsRenderable (this Attachment a) {
return a is RegionAttachment || a is MeshAttachment; return a is IHasRendererObject;
} }
#region Transform Modes #region Transform Modes