mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-25 22:23:42 +08:00
[csharp] Format all source code using formatters/.editorconfig
This commit is contained in:
parent
2aced034d3
commit
d12b15ca8d
@ -442,7 +442,7 @@ namespace Spine {
|
||||
/// <param name="bezierCount">The maximum number of Bezier curves. See <see cref="Shrink(int)"/>.</param>
|
||||
/// <param name="propertyIds">Unique identifiers for the properties the timeline modifies.</param>
|
||||
public CurveTimeline2 (int frameCount, int bezierCount, string propertyId1, string propertyId2)
|
||||
:base (frameCount, bezierCount, propertyId1, propertyId2) {
|
||||
: base(frameCount, bezierCount, propertyId1, propertyId2) {
|
||||
}
|
||||
|
||||
public override int FrameEntries {
|
||||
@ -515,7 +515,7 @@ namespace Spine {
|
||||
public TranslateTimeline (int frameCount, int bezierCount, int boneIndex)
|
||||
: base(frameCount, bezierCount, //
|
||||
(int)Property.X + "|" + boneIndex, //
|
||||
(int) Property.Y + "|" + boneIndex) {
|
||||
(int)Property.Y + "|" + boneIndex) {
|
||||
this.boneIndex = boneIndex;
|
||||
}
|
||||
|
||||
@ -2077,7 +2077,7 @@ namespace Spine {
|
||||
/// <param name="frame">Between 0 and <code>frameCount</code>, inclusive.</param>
|
||||
public void SetFrame (int frame, Event e) {
|
||||
frames[frame] = e.time;
|
||||
events [frame] = e;
|
||||
events[frame] = e;
|
||||
}
|
||||
|
||||
/// <summary>Fires events for frames > <code>lastTime</code> and <= <code>time</code>.</summary>
|
||||
@ -2411,7 +2411,7 @@ namespace Spine {
|
||||
readonly int pathConstraintIndex;
|
||||
|
||||
public PathConstraintPositionTimeline (int frameCount, int bezierCount, int pathConstraintIndex)
|
||||
:base(frameCount, bezierCount, (int)Property.PathConstraintPosition + "|" + pathConstraintIndex) {
|
||||
: base(frameCount, bezierCount, (int)Property.PathConstraintPosition + "|" + pathConstraintIndex) {
|
||||
this.pathConstraintIndex = pathConstraintIndex;
|
||||
}
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ namespace Spine {
|
||||
/// out position.
|
||||
internal const int HoldMix = 4;
|
||||
|
||||
internal const int Setup = 1, Current = 2;
|
||||
internal const int Setup = 1, Current = 2;
|
||||
|
||||
protected AnimationStateData data;
|
||||
private readonly ExposedList<TrackEntry> tracks = new ExposedList<TrackEntry>();
|
||||
@ -510,15 +510,15 @@ namespace Spine {
|
||||
float r1, r2;
|
||||
if (time < frames[0]) { // Time is before first frame.
|
||||
switch (blend) {
|
||||
case MixBlend.Setup:
|
||||
bone.rotation = bone.data.rotation;
|
||||
goto default; // Fall through.
|
||||
default:
|
||||
return;
|
||||
case MixBlend.First:
|
||||
r1 = bone.rotation;
|
||||
r2 = bone.data.rotation;
|
||||
break;
|
||||
case MixBlend.Setup:
|
||||
bone.rotation = bone.data.rotation;
|
||||
goto default; // Fall through.
|
||||
default:
|
||||
return;
|
||||
case MixBlend.First:
|
||||
r1 = bone.rotation;
|
||||
r2 = bone.data.rotation;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
r1 = blend == MixBlend.Setup ? bone.data.rotation : bone.rotation;
|
||||
@ -590,7 +590,7 @@ namespace Spine {
|
||||
/// <para>
|
||||
/// It may be desired to use <see cref="AnimationState.SetEmptyAnimations(float)"/> to mix the skeletons back to the setup pose,
|
||||
/// rather than leaving them in their current pose.</para>
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
public void ClearTracks () {
|
||||
bool oldDrainDisabled = queue.drainDisabled;
|
||||
queue.drainDisabled = true;
|
||||
@ -896,7 +896,7 @@ namespace Spine {
|
||||
}
|
||||
timelineMode[i] = AnimationState.HoldFirst;
|
||||
}
|
||||
continue_outer: {}
|
||||
continue_outer: { }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -261,7 +261,7 @@ namespace Spine {
|
||||
int colon = line.IndexOf(':');
|
||||
if (colon == -1) return 0;
|
||||
entry[0] = line.Substring(0, colon).Trim();
|
||||
for (int i = 1, lastMatch = colon + 1;; i++) {
|
||||
for (int i = 1, lastMatch = colon + 1; ; i++) {
|
||||
int comma = line.IndexOf(',', lastMatch);
|
||||
if (comma == -1) {
|
||||
entry[i] = line.Substring(lastMatch).Trim();
|
||||
|
||||
@ -89,7 +89,7 @@ namespace Spine {
|
||||
return new PointAttachment(name);
|
||||
}
|
||||
|
||||
public ClippingAttachment NewClippingAttachment(Skin skin, string name) {
|
||||
public ClippingAttachment NewClippingAttachment (Skin skin, string name) {
|
||||
return new ClippingAttachment(name);
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ namespace Spine {
|
||||
|
||||
public SlotData EndSlot { get { return endSlot; } set { endSlot = value; } }
|
||||
|
||||
public ClippingAttachment(string name) : base(name) {
|
||||
public ClippingAttachment (string name) : base(name) {
|
||||
}
|
||||
|
||||
public override Attachment Copy () {
|
||||
|
||||
@ -129,7 +129,7 @@ namespace Spine {
|
||||
width = RegionOriginalHeight / textureWidth;
|
||||
height = RegionOriginalWidth / textureHeight;
|
||||
|
||||
for (int i = 0, n = uvs.Length; i<n; i += 2) {
|
||||
for (int i = 0, n = uvs.Length; i < n; i += 2) {
|
||||
uvs[i] = u + (1 - regionUVs[i + 1]) * width;
|
||||
uvs[i + 1] = v + regionUVs[i] * height;
|
||||
}
|
||||
|
||||
@ -30,8 +30,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
namespace Spine {
|
||||
/// <summary>The base class for all constraint datas.</summary>
|
||||
public abstract class ConstraintData {
|
||||
internal readonly string name;
|
||||
|
||||
@ -298,7 +298,7 @@ namespace Spine {
|
||||
|
||||
private int GetLastIndex (int startIndex, int count, Predicate<T> match) {
|
||||
// unlike FindLastIndex, takes regular params for search range
|
||||
for (int i = startIndex + count; i != startIndex; )
|
||||
for (int i = startIndex + count; i != startIndex;)
|
||||
if (match(Items[--i]))
|
||||
return i;
|
||||
return -1;
|
||||
|
||||
@ -166,27 +166,27 @@ namespace Spine {
|
||||
float rotationIK = -bone.ashearX - bone.arotation;
|
||||
float tx = 0, ty = 0;
|
||||
|
||||
switch(bone.data.transformMode) {
|
||||
case TransformMode.OnlyTranslation:
|
||||
tx = targetX - bone.worldX;
|
||||
ty = targetY - bone.worldY;
|
||||
break;
|
||||
case TransformMode.NoRotationOrReflection: {
|
||||
float s = Math.Abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
|
||||
float sa = pa / bone.skeleton.ScaleX;
|
||||
float sc = pc / bone.skeleton.ScaleY;
|
||||
pb = -sc * s * bone.skeleton.ScaleX;
|
||||
pd = sa * s * bone.skeleton.ScaleY;
|
||||
rotationIK += (float)Math.Atan2(sc, sa) * MathUtils.RadDeg;
|
||||
goto default; // Fall through.
|
||||
}
|
||||
default: {
|
||||
float x = targetX - p.worldX, y = targetY - p.worldY;
|
||||
float d = pa * pd - pb * pc;
|
||||
tx = (x * pd - y * pb) / d - bone.ax;
|
||||
ty = (y * pa - x * pc) / d - bone.ay;
|
||||
break;
|
||||
}
|
||||
switch (bone.data.transformMode) {
|
||||
case TransformMode.OnlyTranslation:
|
||||
tx = targetX - bone.worldX;
|
||||
ty = targetY - bone.worldY;
|
||||
break;
|
||||
case TransformMode.NoRotationOrReflection: {
|
||||
float s = Math.Abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
|
||||
float sa = pa / bone.skeleton.ScaleX;
|
||||
float sc = pc / bone.skeleton.ScaleY;
|
||||
pb = -sc * s * bone.skeleton.ScaleX;
|
||||
pd = sa * s * bone.skeleton.ScaleY;
|
||||
rotationIK += (float)Math.Atan2(sc, sa) * MathUtils.RadDeg;
|
||||
goto default; // Fall through.
|
||||
}
|
||||
default: {
|
||||
float x = targetX - p.worldX, y = targetY - p.worldY;
|
||||
float d = pa * pd - pb * pc;
|
||||
tx = (x * pd - y * pb) / d - bone.ax;
|
||||
ty = (y * pa - x * pc) / d - bone.ay;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rotationIK += (float)Math.Atan2(ty, tx) * MathUtils.RadDeg;
|
||||
@ -199,11 +199,11 @@ namespace Spine {
|
||||
float sx = bone.ascaleX, sy = bone.ascaleY;
|
||||
if (compress || stretch) {
|
||||
switch (bone.data.transformMode) {
|
||||
case TransformMode.NoScale:
|
||||
case TransformMode.NoScaleOrReflection:
|
||||
tx = targetX - bone.worldX;
|
||||
ty = targetY - bone.worldY;
|
||||
break;
|
||||
case TransformMode.NoScale:
|
||||
case TransformMode.NoScaleOrReflection:
|
||||
tx = targetX - bone.worldX;
|
||||
ty = targetY - bone.worldY;
|
||||
break;
|
||||
}
|
||||
float b = bone.data.length * sx, dd = (float)Math.Sqrt(tx * tx + ty * ty);
|
||||
if ((compress && dd < b) || (stretch && dd > b) && b > 0.0001f) {
|
||||
|
||||
@ -28,11 +28,11 @@
|
||||
*****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spine {
|
||||
public static class Json {
|
||||
@ -70,10 +70,8 @@ namespace Spine {
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
namespace SharpJson
|
||||
{
|
||||
class Lexer
|
||||
{
|
||||
namespace SharpJson {
|
||||
class Lexer {
|
||||
public enum Token {
|
||||
None,
|
||||
Null,
|
||||
@ -110,23 +108,20 @@ namespace SharpJson
|
||||
bool success = true;
|
||||
char[] stringBuffer = new char[4096];
|
||||
|
||||
public Lexer(string text)
|
||||
{
|
||||
public Lexer (string text) {
|
||||
Reset();
|
||||
|
||||
json = text.ToCharArray();
|
||||
parseNumbersAsFloat = false;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
public void Reset () {
|
||||
index = 0;
|
||||
lineNumber = 1;
|
||||
success = true;
|
||||
}
|
||||
|
||||
public string ParseString()
|
||||
{
|
||||
public string ParseString () {
|
||||
int idx = 0;
|
||||
StringBuilder builder = null;
|
||||
|
||||
@ -165,8 +160,8 @@ namespace SharpJson
|
||||
case 'b':
|
||||
stringBuffer[idx++] = '\b';
|
||||
break;
|
||||
case'f':
|
||||
stringBuffer[idx++] = '\f';
|
||||
case 'f':
|
||||
stringBuffer[idx++] = '\f';
|
||||
break;
|
||||
case 'n':
|
||||
stringBuffer[idx++] = '\n';
|
||||
@ -183,7 +178,7 @@ namespace SharpJson
|
||||
var hex = new string(json, index, 4);
|
||||
|
||||
// XXX: handle UTF
|
||||
stringBuffer[idx++] = (char) Convert.ToInt32(hex, 16);
|
||||
stringBuffer[idx++] = (char)Convert.ToInt32(hex, 16);
|
||||
|
||||
// skip 4 chars
|
||||
index += 4;
|
||||
@ -211,40 +206,37 @@ namespace SharpJson
|
||||
}
|
||||
|
||||
if (builder != null)
|
||||
return builder.ToString ();
|
||||
return builder.ToString();
|
||||
else
|
||||
return new string (stringBuffer, 0, idx);
|
||||
return new string(stringBuffer, 0, idx);
|
||||
}
|
||||
|
||||
string GetNumberString()
|
||||
{
|
||||
string GetNumberString () {
|
||||
SkipWhiteSpaces();
|
||||
|
||||
int lastIndex = GetLastIndexOfNumber(index);
|
||||
int charLength = (lastIndex - index) + 1;
|
||||
|
||||
var result = new string (json, index, charLength);
|
||||
var result = new string(json, index, charLength);
|
||||
|
||||
index = lastIndex + 1;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public float ParseFloatNumber()
|
||||
{
|
||||
public float ParseFloatNumber () {
|
||||
float number;
|
||||
var str = GetNumberString ();
|
||||
var str = GetNumberString();
|
||||
|
||||
if (!float.TryParse (str, NumberStyles.Float, CultureInfo.InvariantCulture, out number))
|
||||
if (!float.TryParse(str, NumberStyles.Float, CultureInfo.InvariantCulture, out number))
|
||||
return 0;
|
||||
|
||||
return number;
|
||||
}
|
||||
|
||||
public double ParseDoubleNumber()
|
||||
{
|
||||
public double ParseDoubleNumber () {
|
||||
double number;
|
||||
var str = GetNumberString ();
|
||||
var str = GetNumberString();
|
||||
|
||||
if (!double.TryParse(str, NumberStyles.Any, CultureInfo.InvariantCulture, out number))
|
||||
return 0;
|
||||
@ -252,23 +244,21 @@ namespace SharpJson
|
||||
return number;
|
||||
}
|
||||
|
||||
int GetLastIndexOfNumber(int index)
|
||||
{
|
||||
int GetLastIndexOfNumber (int index) {
|
||||
int lastIndex;
|
||||
|
||||
for (lastIndex = index; lastIndex < json.Length; lastIndex++) {
|
||||
char ch = json[lastIndex];
|
||||
|
||||
if ((ch < '0' || ch > '9') && ch != '+' && ch != '-'
|
||||
&& ch != '.' && ch != 'e' && ch != 'E')
|
||||
&& ch != '.' && ch != 'e' && ch != 'E')
|
||||
break;
|
||||
}
|
||||
|
||||
return lastIndex - 1;
|
||||
}
|
||||
|
||||
void SkipWhiteSpaces()
|
||||
{
|
||||
void SkipWhiteSpaces () {
|
||||
for (; index < json.Length; index++) {
|
||||
char ch = json[index];
|
||||
|
||||
@ -280,22 +270,19 @@ namespace SharpJson
|
||||
}
|
||||
}
|
||||
|
||||
public Token LookAhead()
|
||||
{
|
||||
public Token LookAhead () {
|
||||
SkipWhiteSpaces();
|
||||
|
||||
int savedIndex = index;
|
||||
return NextToken(json, ref savedIndex);
|
||||
}
|
||||
|
||||
public Token NextToken()
|
||||
{
|
||||
public Token NextToken () {
|
||||
SkipWhiteSpaces();
|
||||
return NextToken(json, ref index);
|
||||
}
|
||||
|
||||
static Token NextToken(char[] json, ref int index)
|
||||
{
|
||||
static Token NextToken (char[] json, ref int index) {
|
||||
if (index == json.Length)
|
||||
return Token.None;
|
||||
|
||||
@ -314,8 +301,16 @@ namespace SharpJson
|
||||
return Token.Comma;
|
||||
case '"':
|
||||
return Token.String;
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
case '-':
|
||||
return Token.Number;
|
||||
case ':':
|
||||
@ -329,10 +324,10 @@ namespace SharpJson
|
||||
// false
|
||||
if (remainingLength >= 5) {
|
||||
if (json[index] == 'f' &&
|
||||
json[index + 1] == 'a' &&
|
||||
json[index + 2] == 'l' &&
|
||||
json[index + 3] == 's' &&
|
||||
json[index + 4] == 'e') {
|
||||
json[index + 1] == 'a' &&
|
||||
json[index + 2] == 'l' &&
|
||||
json[index + 3] == 's' &&
|
||||
json[index + 4] == 'e') {
|
||||
index += 5;
|
||||
return Token.False;
|
||||
}
|
||||
@ -341,9 +336,9 @@ namespace SharpJson
|
||||
// true
|
||||
if (remainingLength >= 4) {
|
||||
if (json[index] == 't' &&
|
||||
json[index + 1] == 'r' &&
|
||||
json[index + 2] == 'u' &&
|
||||
json[index + 3] == 'e') {
|
||||
json[index + 1] == 'r' &&
|
||||
json[index + 2] == 'u' &&
|
||||
json[index + 3] == 'e') {
|
||||
index += 4;
|
||||
return Token.True;
|
||||
}
|
||||
@ -352,9 +347,9 @@ namespace SharpJson
|
||||
// null
|
||||
if (remainingLength >= 4) {
|
||||
if (json[index] == 'n' &&
|
||||
json[index + 1] == 'u' &&
|
||||
json[index + 2] == 'l' &&
|
||||
json[index + 3] == 'l') {
|
||||
json[index + 1] == 'u' &&
|
||||
json[index + 2] == 'l' &&
|
||||
json[index + 3] == 'l') {
|
||||
index += 4;
|
||||
return Token.Null;
|
||||
}
|
||||
@ -364,8 +359,7 @@ namespace SharpJson
|
||||
}
|
||||
}
|
||||
|
||||
public class JsonDecoder
|
||||
{
|
||||
public class JsonDecoder {
|
||||
public string errorMessage {
|
||||
get;
|
||||
private set;
|
||||
@ -378,14 +372,12 @@ namespace SharpJson
|
||||
|
||||
Lexer lexer;
|
||||
|
||||
public JsonDecoder()
|
||||
{
|
||||
public JsonDecoder () {
|
||||
errorMessage = null;
|
||||
parseNumbersAsFloat = false;
|
||||
}
|
||||
|
||||
public object Decode(string text)
|
||||
{
|
||||
public object Decode (string text) {
|
||||
errorMessage = null;
|
||||
|
||||
lexer = new Lexer(text);
|
||||
@ -394,14 +386,12 @@ namespace SharpJson
|
||||
return ParseValue();
|
||||
}
|
||||
|
||||
public static object DecodeText(string text)
|
||||
{
|
||||
public static object DecodeText (string text) {
|
||||
var builder = new JsonDecoder();
|
||||
return builder.Decode(text);
|
||||
}
|
||||
|
||||
IDictionary<string, object> ParseObject()
|
||||
{
|
||||
IDictionary<string, object> ParseObject () {
|
||||
var table = new Dictionary<string, object>();
|
||||
|
||||
// {
|
||||
@ -449,8 +439,7 @@ namespace SharpJson
|
||||
//return null; // Unreachable code
|
||||
}
|
||||
|
||||
IList<object> ParseArray()
|
||||
{
|
||||
IList<object> ParseArray () {
|
||||
var array = new List<object>();
|
||||
|
||||
// [
|
||||
@ -483,8 +472,7 @@ namespace SharpJson
|
||||
//return null; // Unreachable code
|
||||
}
|
||||
|
||||
object ParseValue()
|
||||
{
|
||||
object ParseValue () {
|
||||
switch (lexer.LookAhead()) {
|
||||
case Lexer.Token.String:
|
||||
return EvalLexer(lexer.ParseString());
|
||||
@ -514,14 +502,12 @@ namespace SharpJson
|
||||
return null;
|
||||
}
|
||||
|
||||
void TriggerError(string message)
|
||||
{
|
||||
void TriggerError (string message) {
|
||||
errorMessage = string.Format("Error: '{0}' at line {1}",
|
||||
message, lexer.lineNumber);
|
||||
message, lexer.lineNumber);
|
||||
}
|
||||
|
||||
T EvalLexer<T>(T value)
|
||||
{
|
||||
T EvalLexer<T> (T value) {
|
||||
if (lexer.hasError)
|
||||
TriggerError("Lexical error ocurred");
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ namespace Spine {
|
||||
|
||||
static Random random = new Random();
|
||||
|
||||
#if USE_FAST_SIN_COS_ATAN2_APPROXIMATIONS
|
||||
#if USE_FAST_SIN_COS_ATAN2_APPROXIMATIONS
|
||||
const int SIN_BITS = 14; // 16KB. Adjust for accuracy.
|
||||
const int SIN_MASK = ~(-1 << SIN_BITS);
|
||||
const int SIN_COUNT = SIN_MASK + 1;
|
||||
@ -94,7 +94,7 @@ namespace Spine {
|
||||
atan = PI / 2 - z / (z * z + 0.28f);
|
||||
return y < 0f ? atan - PI : atan;
|
||||
}
|
||||
#else
|
||||
#else
|
||||
/// <summary>Returns the sine of a given angle in radians.</summary>
|
||||
static public float Sin (float radians) {
|
||||
return (float)Math.Sin(radians);
|
||||
@ -119,18 +119,18 @@ namespace Spine {
|
||||
static public float Atan2 (float y, float x) {
|
||||
return (float)Math.Atan2(y, x);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
static public float Clamp (float value, float min, float max) {
|
||||
if (value < min) return min;
|
||||
if (value > max) return max;
|
||||
return value;
|
||||
}
|
||||
|
||||
static public float RandomTriangle(float min, float max) {
|
||||
static public float RandomTriangle (float min, float max) {
|
||||
return RandomTriangle(min, max, (min + max) * 0.5f);
|
||||
}
|
||||
|
||||
static public float RandomTriangle(float min, float max, float mode) {
|
||||
static public float RandomTriangle (float min, float max, float mode) {
|
||||
float u = (float)random.NextDouble();
|
||||
float d = max - min;
|
||||
if (u <= (mode - min) / d) return min + (float)Math.Sqrt(u * d * (mode - min));
|
||||
@ -142,31 +142,31 @@ namespace Spine {
|
||||
public static IInterpolation Pow2 = new Pow(2);
|
||||
public static IInterpolation Pow2Out = new PowOut(2);
|
||||
|
||||
protected abstract float Apply(float a);
|
||||
protected abstract float Apply (float a);
|
||||
|
||||
public float Apply(float start, float end, float a) {
|
||||
public float Apply (float start, float end, float a) {
|
||||
return start + (end - start) * Apply(a);
|
||||
}
|
||||
}
|
||||
|
||||
public class Pow: IInterpolation {
|
||||
public class Pow : IInterpolation {
|
||||
public float Power { get; set; }
|
||||
|
||||
public Pow(float power) {
|
||||
public Pow (float power) {
|
||||
Power = power;
|
||||
}
|
||||
|
||||
protected override float Apply(float a) {
|
||||
protected override float Apply (float a) {
|
||||
if (a <= 0.5f) return (float)Math.Pow(a * 2, Power) / 2;
|
||||
return (float)Math.Pow((a - 1) * 2, Power) / (Power % 2 == 0 ? -2 : 2) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
public class PowOut : Pow {
|
||||
public PowOut(float power) : base(power) {
|
||||
public PowOut (float power) : base(power) {
|
||||
}
|
||||
|
||||
protected override float Apply(float a) {
|
||||
protected override float Apply (float a) {
|
||||
return (float)Math.Pow(a - 1, Power) * (Power % 2 == 0 ? -1 : 1) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,7 +272,7 @@ namespace Spine {
|
||||
}
|
||||
|
||||
// Determine curve containing position.
|
||||
for (;; curve++) {
|
||||
for (; ; curve++) {
|
||||
float length = lengths[curve];
|
||||
if (p > length) continue;
|
||||
if (curve == 0)
|
||||
@ -383,7 +383,7 @@ namespace Spine {
|
||||
}
|
||||
|
||||
// Determine curve containing position.
|
||||
for (;; curve++) {
|
||||
for (; ; curve++) {
|
||||
float length = curves[curve];
|
||||
if (p > length) continue;
|
||||
if (curve == 0)
|
||||
@ -438,7 +438,7 @@ namespace Spine {
|
||||
|
||||
// Weight by segment length.
|
||||
p *= curveLength;
|
||||
for (;; segment++) {
|
||||
for (; ; segment++) {
|
||||
float length = segments[segment];
|
||||
if (p > length) continue;
|
||||
if (segment == 0)
|
||||
|
||||
@ -117,7 +117,7 @@ namespace Spine {
|
||||
foreach (TransformConstraintData transformConstraintData in data.transformConstraints)
|
||||
transformConstraints.Add(new TransformConstraint(transformConstraintData, this));
|
||||
|
||||
pathConstraints = new ExposedList<PathConstraint> (data.pathConstraints.Count);
|
||||
pathConstraints = new ExposedList<PathConstraint>(data.pathConstraints.Count);
|
||||
foreach (PathConstraintData pathConstraintData in data.pathConstraints)
|
||||
pathConstraints.Add(new PathConstraint(pathConstraintData, this));
|
||||
|
||||
@ -177,7 +177,7 @@ namespace Spine {
|
||||
goto continue_outer;
|
||||
}
|
||||
}
|
||||
continue_outer: {}
|
||||
continue_outer: { }
|
||||
}
|
||||
|
||||
for (int i = 0; i < boneCount; i++)
|
||||
@ -332,7 +332,7 @@ namespace Spine {
|
||||
/// <summary>
|
||||
/// Temporarily sets the root bone as a child of the specified bone, then updates the world transform for each bone and applies
|
||||
/// all constraints.
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
public void UpdateWorldTransform (Bone parent) {
|
||||
if (parent == null) throw new ArgumentNullException("parent", "parent cannot be null.");
|
||||
|
||||
@ -472,7 +472,7 @@ namespace Spine {
|
||||
/// <para>Sets the skin used to look up attachments before looking in the <see cref="SkeletonData.DefaultSkin"/>. If the
|
||||
/// skin is changed, <see cref="UpdateCache()"/> is called.
|
||||
/// </para>
|
||||
/// <para>Attachments from the new skin are attached if the corresponding attachment from the old skin was attached.
|
||||
/// <para>Attachments from the new skin are attached if the corresponding attachment from the old skin was attached.
|
||||
/// If there was no old skin, each slot's setup mode attachment is attached from the new skin.
|
||||
/// </para>
|
||||
/// <para>After changing the skin, the visible attachments can be reset to those attached in the setup pose by calling
|
||||
|
||||
@ -32,8 +32,8 @@
|
||||
#endif
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
#if WINDOWS_STOREAPP
|
||||
@ -70,7 +70,7 @@ namespace Spine {
|
||||
public const int CURVE_BEZIER = 2;
|
||||
|
||||
public SkeletonBinary (AttachmentLoader attachmentLoader)
|
||||
:base(attachmentLoader) {
|
||||
: base(attachmentLoader) {
|
||||
}
|
||||
|
||||
public SkeletonBinary (params Atlas[] atlasArray)
|
||||
@ -92,17 +92,17 @@ namespace Spine {
|
||||
}
|
||||
#else
|
||||
public override SkeletonData ReadSkeletonData (string path) {
|
||||
#if WINDOWS_PHONE
|
||||
#if WINDOWS_PHONE
|
||||
using (var input = new BufferedStream(Microsoft.Xna.Framework.TitleContainer.OpenStream(path))) {
|
||||
#else
|
||||
#else
|
||||
using (var input = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) {
|
||||
#endif
|
||||
#endif
|
||||
SkeletonData skeletonData = ReadSkeletonData(input);
|
||||
skeletonData.name = Path.GetFileNameWithoutExtension(path);
|
||||
return skeletonData;
|
||||
}
|
||||
}
|
||||
#endif // WINDOWS_STOREAPP
|
||||
#endif // WINDOWS_STOREAPP
|
||||
|
||||
public static readonly TransformMode[] TransformModeValues = {
|
||||
TransformMode.Normal,
|
||||
@ -539,7 +539,7 @@ namespace Spine {
|
||||
float scale = this.scale;
|
||||
int verticesLength = vertexCount << 1;
|
||||
Vertices vertices = new Vertices();
|
||||
if(!input.ReadBoolean()) {
|
||||
if (!input.ReadBoolean()) {
|
||||
vertices.vertices = ReadFloatArray(input, verticesLength, scale);
|
||||
return vertices;
|
||||
}
|
||||
@ -593,167 +593,167 @@ namespace Spine {
|
||||
for (int ii = 0, nn = input.ReadInt(true); ii < nn; ii++) {
|
||||
int timelineType = input.ReadByte(), frameCount = input.ReadInt(true), frameLast = frameCount - 1;
|
||||
switch (timelineType) {
|
||||
case SLOT_ATTACHMENT: {
|
||||
AttachmentTimeline timeline = new AttachmentTimeline(frameCount, slotIndex);
|
||||
for (int frame = 0; frame < frameCount; frame++)
|
||||
timeline.SetFrame(frame, input.ReadFloat(), input.ReadStringRef());
|
||||
timelines.Add(timeline);
|
||||
case SLOT_ATTACHMENT: {
|
||||
AttachmentTimeline timeline = new AttachmentTimeline(frameCount, slotIndex);
|
||||
for (int frame = 0; frame < frameCount; frame++)
|
||||
timeline.SetFrame(frame, input.ReadFloat(), input.ReadStringRef());
|
||||
timelines.Add(timeline);
|
||||
break;
|
||||
}
|
||||
case SLOT_RGBA: {
|
||||
RGBATimeline timeline = new RGBATimeline(frameCount, input.ReadInt(true), slotIndex);
|
||||
float time = input.ReadFloat();
|
||||
float r = input.Read() / 255f, g = input.Read() / 255f;
|
||||
float b = input.Read() / 255f, a = input.Read() / 255f;
|
||||
for (int frame = 0, bezier = 0; ; frame++) {
|
||||
timeline.SetFrame(frame, time, r, g, b, a);
|
||||
if (frame == frameLast) break;
|
||||
float time2 = input.ReadFloat();
|
||||
float r2 = input.Read() / 255f, g2 = input.Read() / 255f;
|
||||
float b2 = input.Read() / 255f, a2 = input.Read() / 255f;
|
||||
switch (input.ReadByte()) {
|
||||
case CURVE_STEPPED:
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, r, r2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 1, time, time2, g, g2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 2, time, time2, b, b2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 3, time, time2, a, a2, 1);
|
||||
break;
|
||||
}
|
||||
case SLOT_RGBA: {
|
||||
RGBATimeline timeline = new RGBATimeline(frameCount, input.ReadInt(true), slotIndex);
|
||||
float time = input.ReadFloat();
|
||||
float r = input.Read() / 255f, g = input.Read() / 255f;
|
||||
float b = input.Read() / 255f, a = input.Read() / 255f;
|
||||
for (int frame = 0, bezier = 0; ; frame++) {
|
||||
timeline.SetFrame(frame, time, r, g, b, a);
|
||||
if (frame == frameLast) break;
|
||||
float time2 = input.ReadFloat();
|
||||
float r2 = input.Read() / 255f, g2 = input.Read() / 255f;
|
||||
float b2 = input.Read() / 255f, a2 = input.Read() / 255f;
|
||||
switch (input.ReadByte()) {
|
||||
case CURVE_STEPPED:
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, r, r2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 1, time, time2, g, g2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 2, time, time2, b, b2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 3, time, time2, a, a2, 1);
|
||||
break;
|
||||
}
|
||||
time = time2;
|
||||
r = r2;
|
||||
g = g2;
|
||||
b = b2;
|
||||
a = a2;
|
||||
}
|
||||
timelines.Add(timeline);
|
||||
time = time2;
|
||||
r = r2;
|
||||
g = g2;
|
||||
b = b2;
|
||||
a = a2;
|
||||
}
|
||||
timelines.Add(timeline);
|
||||
break;
|
||||
}
|
||||
case SLOT_RGB: {
|
||||
RGBTimeline timeline = new RGBTimeline(frameCount, input.ReadInt(true), slotIndex);
|
||||
float time = input.ReadFloat();
|
||||
float r = input.Read() / 255f, g = input.Read() / 255f, b = input.Read() / 255f;
|
||||
for (int frame = 0, bezier = 0; ; frame++) {
|
||||
timeline.SetFrame(frame, time, r, g, b);
|
||||
if (frame == frameLast) break;
|
||||
float time2 = input.ReadFloat();
|
||||
float r2 = input.Read() / 255f, g2 = input.Read() / 255f, b2 = input.Read() / 255f;
|
||||
switch (input.ReadByte()) {
|
||||
case CURVE_STEPPED:
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, r, r2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 1, time, time2, g, g2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 2, time, time2, b, b2, 1);
|
||||
break;
|
||||
}
|
||||
case SLOT_RGB: {
|
||||
RGBTimeline timeline = new RGBTimeline(frameCount, input.ReadInt(true), slotIndex);
|
||||
float time = input.ReadFloat();
|
||||
float r = input.Read() / 255f, g = input.Read() / 255f, b = input.Read() / 255f;
|
||||
for (int frame = 0, bezier = 0; ; frame++) {
|
||||
timeline.SetFrame(frame, time, r, g, b);
|
||||
if (frame == frameLast) break;
|
||||
float time2 = input.ReadFloat();
|
||||
float r2 = input.Read() / 255f, g2 = input.Read() / 255f, b2 = input.Read() / 255f;
|
||||
switch (input.ReadByte()) {
|
||||
case CURVE_STEPPED:
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, r, r2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 1, time, time2, g, g2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 2, time, time2, b, b2, 1);
|
||||
break;
|
||||
}
|
||||
time = time2;
|
||||
r = r2;
|
||||
g = g2;
|
||||
b = b2;
|
||||
}
|
||||
timelines.Add(timeline);
|
||||
time = time2;
|
||||
r = r2;
|
||||
g = g2;
|
||||
b = b2;
|
||||
}
|
||||
timelines.Add(timeline);
|
||||
break;
|
||||
}
|
||||
case SLOT_RGBA2: {
|
||||
RGBA2Timeline timeline = new RGBA2Timeline(frameCount, input.ReadInt(true), slotIndex);
|
||||
float time = input.ReadFloat();
|
||||
float r = input.Read() / 255f, g = input.Read() / 255f;
|
||||
float b = input.Read() / 255f, a = input.Read() / 255f;
|
||||
float r2 = input.Read() / 255f, g2 = input.Read() / 255f, b2 = input.Read() / 255f;
|
||||
for (int frame = 0, bezier = 0; ; frame++) {
|
||||
timeline.SetFrame(frame, time, r, g, b, a, r2, g2, b2);
|
||||
if (frame == frameLast) break;
|
||||
float time2 = input.ReadFloat();
|
||||
float nr = input.Read() / 255f, ng = input.Read() / 255f;
|
||||
float nb = input.Read() / 255f, na = input.Read() / 255f;
|
||||
float nr2 = input.Read() / 255f, ng2 = input.Read() / 255f, nb2 = input.Read() / 255f;
|
||||
switch (input.ReadByte()) {
|
||||
case CURVE_STEPPED:
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, r, nr, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 1, time, time2, g, ng, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 2, time, time2, b, nb, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 3, time, time2, a, na, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 4, time, time2, r2, nr2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 5, time, time2, g2, ng2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 6, time, time2, b2, nb2, 1);
|
||||
break;
|
||||
}
|
||||
case SLOT_RGBA2: {
|
||||
RGBA2Timeline timeline = new RGBA2Timeline(frameCount, input.ReadInt(true), slotIndex);
|
||||
float time = input.ReadFloat();
|
||||
float r = input.Read() / 255f, g = input.Read() / 255f;
|
||||
float b = input.Read() / 255f, a = input.Read() / 255f;
|
||||
float r2 = input.Read() / 255f, g2 = input.Read() / 255f, b2 = input.Read() / 255f;
|
||||
for (int frame = 0, bezier = 0; ; frame++) {
|
||||
timeline.SetFrame(frame, time, r, g, b, a, r2, g2, b2);
|
||||
if (frame == frameLast) break;
|
||||
float time2 = input.ReadFloat();
|
||||
float nr = input.Read() / 255f, ng = input.Read() / 255f;
|
||||
float nb = input.Read() / 255f, na = input.Read() / 255f;
|
||||
float nr2 = input.Read() / 255f, ng2 = input.Read() / 255f, nb2 = input.Read() / 255f;
|
||||
switch (input.ReadByte()) {
|
||||
case CURVE_STEPPED:
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, r, nr, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 1, time, time2, g, ng, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 2, time, time2, b, nb, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 3, time, time2, a, na, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 4, time, time2, r2, nr2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 5, time, time2, g2, ng2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 6, time, time2, b2, nb2, 1);
|
||||
break;
|
||||
}
|
||||
time = time2;
|
||||
r = nr;
|
||||
g = ng;
|
||||
b = nb;
|
||||
a = na;
|
||||
r2 = nr2;
|
||||
g2 = ng2;
|
||||
b2 = nb2;
|
||||
}
|
||||
timelines.Add(timeline);
|
||||
time = time2;
|
||||
r = nr;
|
||||
g = ng;
|
||||
b = nb;
|
||||
a = na;
|
||||
r2 = nr2;
|
||||
g2 = ng2;
|
||||
b2 = nb2;
|
||||
}
|
||||
timelines.Add(timeline);
|
||||
break;
|
||||
}
|
||||
case SLOT_RGB2: {
|
||||
RGB2Timeline timeline = new RGB2Timeline(frameCount, input.ReadInt(true), slotIndex);
|
||||
float time = input.ReadFloat();
|
||||
float r = input.Read() / 255f, g = input.Read() / 255f, b = input.Read() / 255f;
|
||||
float r2 = input.Read() / 255f, g2 = input.Read() / 255f, b2 = input.Read() / 255f;
|
||||
for (int frame = 0, bezier = 0; ; frame++) {
|
||||
timeline.SetFrame(frame, time, r, g, b, r2, g2, b2);
|
||||
if (frame == frameLast) break;
|
||||
float time2 = input.ReadFloat();
|
||||
float nr = input.Read() / 255f, ng = input.Read() / 255f, nb = input.Read() / 255f;
|
||||
float nr2 = input.Read() / 255f, ng2 = input.Read() / 255f, nb2 = input.Read() / 255f;
|
||||
switch (input.ReadByte()) {
|
||||
case CURVE_STEPPED:
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, r, nr, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 1, time, time2, g, ng, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 2, time, time2, b, nb, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 3, time, time2, r2, nr2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 4, time, time2, g2, ng2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 5, time, time2, b2, nb2, 1);
|
||||
break;
|
||||
}
|
||||
case SLOT_RGB2: {
|
||||
RGB2Timeline timeline = new RGB2Timeline(frameCount, input.ReadInt(true), slotIndex);
|
||||
float time = input.ReadFloat();
|
||||
float r = input.Read() / 255f, g = input.Read() / 255f, b = input.Read() / 255f;
|
||||
float r2 = input.Read() / 255f, g2 = input.Read() / 255f, b2 = input.Read() / 255f;
|
||||
for (int frame = 0, bezier = 0; ; frame++) {
|
||||
timeline.SetFrame(frame, time, r, g, b, r2, g2, b2);
|
||||
if (frame == frameLast) break;
|
||||
float time2 = input.ReadFloat();
|
||||
float nr = input.Read() / 255f, ng = input.Read() / 255f, nb = input.Read() / 255f;
|
||||
float nr2 = input.Read() / 255f, ng2 = input.Read() / 255f, nb2 = input.Read() / 255f;
|
||||
switch (input.ReadByte()) {
|
||||
case CURVE_STEPPED:
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, r, nr, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 1, time, time2, g, ng, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 2, time, time2, b, nb, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 3, time, time2, r2, nr2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 4, time, time2, g2, ng2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 5, time, time2, b2, nb2, 1);
|
||||
break;
|
||||
}
|
||||
time = time2;
|
||||
r = nr;
|
||||
g = ng;
|
||||
b = nb;
|
||||
r2 = nr2;
|
||||
g2 = ng2;
|
||||
b2 = nb2;
|
||||
}
|
||||
timelines.Add(timeline);
|
||||
break;
|
||||
}
|
||||
case SLOT_ALPHA: {
|
||||
AlphaTimeline timeline = new AlphaTimeline(frameCount, input.ReadInt(true), slotIndex);
|
||||
float time = input.ReadFloat(), a = input.Read() / 255f;
|
||||
for (int frame = 0, bezier = 0; ; frame++) {
|
||||
timeline.SetFrame(frame, time, a);
|
||||
if (frame == frameLast) break;
|
||||
float time2 = input.ReadFloat();
|
||||
float a2 = input.Read() / 255f;
|
||||
switch (input.ReadByte()) {
|
||||
case CURVE_STEPPED:
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, a, a2, 1);
|
||||
break;
|
||||
}
|
||||
time = time2;
|
||||
a = a2;
|
||||
}
|
||||
timelines.Add(timeline);
|
||||
time = time2;
|
||||
r = nr;
|
||||
g = ng;
|
||||
b = nb;
|
||||
r2 = nr2;
|
||||
g2 = ng2;
|
||||
b2 = nb2;
|
||||
}
|
||||
timelines.Add(timeline);
|
||||
break;
|
||||
}
|
||||
case SLOT_ALPHA: {
|
||||
AlphaTimeline timeline = new AlphaTimeline(frameCount, input.ReadInt(true), slotIndex);
|
||||
float time = input.ReadFloat(), a = input.Read() / 255f;
|
||||
for (int frame = 0, bezier = 0; ; frame++) {
|
||||
timeline.SetFrame(frame, time, a);
|
||||
if (frame == frameLast) break;
|
||||
float time2 = input.ReadFloat();
|
||||
float a2 = input.Read() / 255f;
|
||||
switch (input.ReadByte()) {
|
||||
case CURVE_STEPPED:
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, a, a2, 1);
|
||||
break;
|
||||
}
|
||||
time = time2;
|
||||
a = a2;
|
||||
}
|
||||
timelines.Add(timeline);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -764,36 +764,36 @@ namespace Spine {
|
||||
for (int ii = 0, nn = input.ReadInt(true); ii < nn; ii++) {
|
||||
int type = input.ReadByte(), frameCount = input.ReadInt(true), bezierCount = input.ReadInt(true);
|
||||
switch (type) {
|
||||
case BONE_ROTATE:
|
||||
timelines.Add(ReadTimeline(input, new RotateTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case BONE_TRANSLATE:
|
||||
timelines.Add(ReadTimeline(input, new TranslateTimeline(frameCount, bezierCount, boneIndex), scale));
|
||||
break;
|
||||
case BONE_TRANSLATEX:
|
||||
timelines.Add(ReadTimeline(input, new TranslateXTimeline(frameCount, bezierCount, boneIndex), scale));
|
||||
break;
|
||||
case BONE_TRANSLATEY:
|
||||
timelines.Add(ReadTimeline(input, new TranslateYTimeline(frameCount, bezierCount, boneIndex), scale));
|
||||
break;
|
||||
case BONE_SCALE:
|
||||
timelines.Add(ReadTimeline(input, new ScaleTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case BONE_SCALEX:
|
||||
timelines.Add(ReadTimeline(input, new ScaleXTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case BONE_SCALEY:
|
||||
timelines.Add(ReadTimeline(input, new ScaleYTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case BONE_SHEAR:
|
||||
timelines.Add(ReadTimeline(input, new ShearTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case BONE_SHEARX:
|
||||
timelines.Add(ReadTimeline(input, new ShearXTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case BONE_SHEARY:
|
||||
timelines.Add(ReadTimeline(input, new ShearYTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case BONE_ROTATE:
|
||||
timelines.Add(ReadTimeline(input, new RotateTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case BONE_TRANSLATE:
|
||||
timelines.Add(ReadTimeline(input, new TranslateTimeline(frameCount, bezierCount, boneIndex), scale));
|
||||
break;
|
||||
case BONE_TRANSLATEX:
|
||||
timelines.Add(ReadTimeline(input, new TranslateXTimeline(frameCount, bezierCount, boneIndex), scale));
|
||||
break;
|
||||
case BONE_TRANSLATEY:
|
||||
timelines.Add(ReadTimeline(input, new TranslateYTimeline(frameCount, bezierCount, boneIndex), scale));
|
||||
break;
|
||||
case BONE_SCALE:
|
||||
timelines.Add(ReadTimeline(input, new ScaleTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case BONE_SCALEX:
|
||||
timelines.Add(ReadTimeline(input, new ScaleXTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case BONE_SCALEY:
|
||||
timelines.Add(ReadTimeline(input, new ScaleYTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case BONE_SHEAR:
|
||||
timelines.Add(ReadTimeline(input, new ShearTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case BONE_SHEARX:
|
||||
timelines.Add(ReadTimeline(input, new ShearXTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case BONE_SHEARY:
|
||||
timelines.Add(ReadTimeline(input, new ShearYTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -808,13 +808,13 @@ namespace Spine {
|
||||
if (frame == frameLast) break;
|
||||
float time2 = input.ReadFloat(), mix2 = input.ReadFloat(), softness2 = input.ReadFloat() * scale;
|
||||
switch (input.ReadByte()) {
|
||||
case CURVE_STEPPED:
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, mix, mix2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 1, time, time2, softness, softness2, scale);
|
||||
break;
|
||||
case CURVE_STEPPED:
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, mix, mix2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 1, time, time2, softness, softness2, scale);
|
||||
break;
|
||||
}
|
||||
time = time2;
|
||||
mix = mix2;
|
||||
@ -835,17 +835,17 @@ namespace Spine {
|
||||
float time2 = input.ReadFloat(), mixRotate2 = input.ReadFloat(), mixX2 = input.ReadFloat(), mixY2 = input.ReadFloat(),
|
||||
mixScaleX2 = input.ReadFloat(), mixScaleY2 = input.ReadFloat(), mixShearY2 = input.ReadFloat();
|
||||
switch (input.ReadByte()) {
|
||||
case CURVE_STEPPED:
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, mixRotate, mixRotate2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 1, time, time2, mixX, mixX2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 2, time, time2, mixY, mixY2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 3, time, time2, mixScaleX, mixScaleX2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 4, time, time2, mixScaleY, mixScaleY2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 5, time, time2, mixShearY, mixShearY2, 1);
|
||||
break;
|
||||
case CURVE_STEPPED:
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, mixRotate, mixRotate2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 1, time, time2, mixX, mixX2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 2, time, time2, mixY, mixY2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 3, time, time2, mixScaleX, mixScaleX2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 4, time, time2, mixScaleY, mixScaleY2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 5, time, time2, mixShearY, mixShearY2, 1);
|
||||
break;
|
||||
}
|
||||
time = time2;
|
||||
mixRotate = mixRotate2;
|
||||
@ -884,14 +884,14 @@ namespace Spine {
|
||||
float time2 = input.ReadFloat(), mixRotate2 = input.ReadFloat(), mixX2 = input.ReadFloat(),
|
||||
mixY2 = input.ReadFloat();
|
||||
switch (input.ReadByte()) {
|
||||
case CURVE_STEPPED:
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, mixRotate, mixRotate2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 1, time, time2, mixX, mixX2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 2, time, time2, mixY, mixY2, 1);
|
||||
break;
|
||||
case CURVE_STEPPED:
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, mixRotate, mixRotate2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 1, time, time2, mixX, mixX2, 1);
|
||||
SetBezier(input, timeline, bezier++, frame, 2, time, time2, mixY, mixY2, 1);
|
||||
break;
|
||||
}
|
||||
time = time2;
|
||||
mixRotate = mixRotate2;
|
||||
@ -1022,7 +1022,7 @@ namespace Spine {
|
||||
/// <exception cref="IOException">Throws IOException when a read operation fails.</exception>
|
||||
private Timeline ReadTimeline (SkeletonInput input, CurveTimeline1 timeline, float scale) {
|
||||
float time = input.ReadFloat(), value = input.ReadFloat() * scale;
|
||||
for (int frame = 0, bezier = 0, frameLast = timeline.FrameCount - 1;; frame++) {
|
||||
for (int frame = 0, bezier = 0, frameLast = timeline.FrameCount - 1; ; frame++) {
|
||||
timeline.SetFrame(frame, time, value);
|
||||
if (frame == frameLast) break;
|
||||
float time2 = input.ReadFloat(), value2 = input.ReadFloat() * scale;
|
||||
@ -1031,8 +1031,8 @@ namespace Spine {
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier (input, timeline, bezier++, frame, 0, time, time2, value, value2, scale);
|
||||
break;
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, value, value2, scale);
|
||||
break;
|
||||
}
|
||||
time = time2;
|
||||
value = value2;
|
||||
@ -1043,18 +1043,18 @@ namespace Spine {
|
||||
/// <exception cref="IOException">Throws IOException when a read operation fails.</exception>
|
||||
private Timeline ReadTimeline (SkeletonInput input, CurveTimeline2 timeline, float scale) {
|
||||
float time = input.ReadFloat(), value1 = input.ReadFloat() * scale, value2 = input.ReadFloat() * scale;
|
||||
for (int frame = 0, bezier = 0, frameLast = timeline.FrameCount - 1;; frame++) {
|
||||
for (int frame = 0, bezier = 0, frameLast = timeline.FrameCount - 1; ; frame++) {
|
||||
timeline.SetFrame(frame, time, value1, value2);
|
||||
if (frame == frameLast) break;
|
||||
float time2 = input.ReadFloat(), nvalue1 = input.ReadFloat() * scale, nvalue2 = input.ReadFloat() * scale;
|
||||
switch (input.ReadByte()) {
|
||||
case CURVE_STEPPED:
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, value1, nvalue1, scale);
|
||||
SetBezier(input, timeline, bezier++, frame, 1, time, time2, value2, nvalue2, scale);
|
||||
break;
|
||||
case CURVE_STEPPED:
|
||||
timeline.SetStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
SetBezier(input, timeline, bezier++, frame, 0, time, time2, value1, nvalue1, scale);
|
||||
SetBezier(input, timeline, bezier++, frame, 1, time, time2, value2, nvalue2, scale);
|
||||
break;
|
||||
}
|
||||
time = time2;
|
||||
value1 = nvalue1;
|
||||
@ -1070,8 +1070,7 @@ namespace Spine {
|
||||
input.ReadFloat() * scale, time2, value2);
|
||||
}
|
||||
|
||||
internal class Vertices
|
||||
{
|
||||
internal class Vertices {
|
||||
public int[] bones;
|
||||
public float[] vertices;
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ namespace Spine {
|
||||
internal ExposedList<IkConstraintData> ikConstraints = new ExposedList<IkConstraintData>();
|
||||
internal ExposedList<TransformConstraintData> transformConstraints = new ExposedList<TransformConstraintData>();
|
||||
internal ExposedList<PathConstraintData> pathConstraints = new ExposedList<PathConstraintData>();
|
||||
internal float x , y, width, height;
|
||||
internal float x, y, width, height;
|
||||
internal string version, hash;
|
||||
|
||||
// Nonessential.
|
||||
|
||||
@ -32,8 +32,8 @@
|
||||
#endif
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
#if WINDOWS_STOREAPP
|
||||
using System.Threading.Tasks;
|
||||
@ -77,17 +77,17 @@ namespace Spine {
|
||||
}
|
||||
#else
|
||||
public override SkeletonData ReadSkeletonData (string path) {
|
||||
#if WINDOWS_PHONE
|
||||
#if WINDOWS_PHONE
|
||||
using (var reader = new StreamReader(Microsoft.Xna.Framework.TitleContainer.OpenStream(path))) {
|
||||
#else
|
||||
#else
|
||||
using (var reader = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))) {
|
||||
#endif
|
||||
#endif
|
||||
SkeletonData skeletonData = ReadSkeletonData(reader);
|
||||
skeletonData.name = Path.GetFileNameWithoutExtension(path);
|
||||
return skeletonData;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
public SkeletonData ReadSkeletonData (TextReader reader) {
|
||||
if (reader == null) throw new ArgumentNullException("reader", "reader cannot be null.");
|
||||
@ -178,7 +178,7 @@ namespace Spine {
|
||||
foreach (Dictionary<string, Object> constraintMap in (List<Object>)root["ik"]) {
|
||||
IkConstraintData data = new IkConstraintData((string)constraintMap["name"]);
|
||||
data.order = GetInt(constraintMap, "order", 0);
|
||||
data.skinRequired = GetBoolean(constraintMap,"skin", false);
|
||||
data.skinRequired = GetBoolean(constraintMap, "skin", false);
|
||||
|
||||
if (constraintMap.ContainsKey("bones")) {
|
||||
foreach (string boneName in (List<Object>)constraintMap["bones"]) {
|
||||
@ -207,7 +207,7 @@ namespace Spine {
|
||||
foreach (Dictionary<string, Object> constraintMap in (List<Object>)root["transform"]) {
|
||||
TransformConstraintData data = new TransformConstraintData((string)constraintMap["name"]);
|
||||
data.order = GetInt(constraintMap, "order", 0);
|
||||
data.skinRequired = GetBoolean(constraintMap,"skin", false);
|
||||
data.skinRequired = GetBoolean(constraintMap, "skin", false);
|
||||
|
||||
if (constraintMap.ContainsKey("bones")) {
|
||||
foreach (string boneName in (List<Object>)constraintMap["bones"]) {
|
||||
@ -243,11 +243,11 @@ namespace Spine {
|
||||
}
|
||||
|
||||
// Path constraints.
|
||||
if(root.ContainsKey("path")) {
|
||||
if (root.ContainsKey("path")) {
|
||||
foreach (Dictionary<string, Object> constraintMap in (List<Object>)root["path"]) {
|
||||
PathConstraintData data = new PathConstraintData((string)constraintMap["name"]);
|
||||
data.order = GetInt(constraintMap, "order", 0);
|
||||
data.skinRequired = GetBoolean(constraintMap,"skin", false);
|
||||
data.skinRequired = GetBoolean(constraintMap, "skin", false);
|
||||
|
||||
if (constraintMap.ContainsKey("bones")) {
|
||||
foreach (string boneName in (List<Object>)constraintMap["bones"]) {
|
||||
@ -418,78 +418,78 @@ namespace Spine {
|
||||
return box;
|
||||
case AttachmentType.Mesh:
|
||||
case AttachmentType.Linkedmesh: {
|
||||
MeshAttachment mesh = attachmentLoader.NewMeshAttachment(skin, name, path);
|
||||
if (mesh == null) return null;
|
||||
mesh.Path = path;
|
||||
MeshAttachment mesh = attachmentLoader.NewMeshAttachment(skin, name, path);
|
||||
if (mesh == null) return null;
|
||||
mesh.Path = path;
|
||||
|
||||
if (map.ContainsKey("color")) {
|
||||
var color = (string)map["color"];
|
||||
mesh.r = ToColor(color, 0);
|
||||
mesh.g = ToColor(color, 1);
|
||||
mesh.b = ToColor(color, 2);
|
||||
mesh.a = ToColor(color, 3);
|
||||
}
|
||||
if (map.ContainsKey("color")) {
|
||||
var color = (string)map["color"];
|
||||
mesh.r = ToColor(color, 0);
|
||||
mesh.g = ToColor(color, 1);
|
||||
mesh.b = ToColor(color, 2);
|
||||
mesh.a = ToColor(color, 3);
|
||||
}
|
||||
|
||||
mesh.Width = GetFloat(map, "width", 0) * scale;
|
||||
mesh.Height = GetFloat(map, "height", 0) * scale;
|
||||
mesh.Width = GetFloat(map, "width", 0) * scale;
|
||||
mesh.Height = GetFloat(map, "height", 0) * scale;
|
||||
|
||||
string parent = GetString(map, "parent", null);
|
||||
if (parent != null) {
|
||||
linkedMeshes.Add(new LinkedMesh(mesh, GetString(map, "skin", null), slotIndex, parent, GetBoolean(map, "deform", true)));
|
||||
return mesh;
|
||||
}
|
||||
|
||||
float[] uvs = GetFloatArray(map, "uvs", 1);
|
||||
ReadVertices(map, mesh, uvs.Length);
|
||||
mesh.triangles = GetIntArray(map, "triangles");
|
||||
mesh.regionUVs = uvs;
|
||||
mesh.UpdateUVs();
|
||||
|
||||
if (map.ContainsKey("hull")) mesh.HullLength = GetInt(map, "hull", 0) << 1;
|
||||
if (map.ContainsKey("edges")) mesh.Edges = GetIntArray(map, "edges");
|
||||
string parent = GetString(map, "parent", null);
|
||||
if (parent != null) {
|
||||
linkedMeshes.Add(new LinkedMesh(mesh, GetString(map, "skin", null), slotIndex, parent, GetBoolean(map, "deform", true)));
|
||||
return mesh;
|
||||
}
|
||||
|
||||
float[] uvs = GetFloatArray(map, "uvs", 1);
|
||||
ReadVertices(map, mesh, uvs.Length);
|
||||
mesh.triangles = GetIntArray(map, "triangles");
|
||||
mesh.regionUVs = uvs;
|
||||
mesh.UpdateUVs();
|
||||
|
||||
if (map.ContainsKey("hull")) mesh.HullLength = GetInt(map, "hull", 0) << 1;
|
||||
if (map.ContainsKey("edges")) mesh.Edges = GetIntArray(map, "edges");
|
||||
return mesh;
|
||||
}
|
||||
case AttachmentType.Path: {
|
||||
PathAttachment pathAttachment = attachmentLoader.NewPathAttachment(skin, name);
|
||||
if (pathAttachment == null) return null;
|
||||
pathAttachment.closed = GetBoolean(map, "closed", false);
|
||||
pathAttachment.constantSpeed = GetBoolean(map, "constantSpeed", true);
|
||||
PathAttachment pathAttachment = attachmentLoader.NewPathAttachment(skin, name);
|
||||
if (pathAttachment == null) return null;
|
||||
pathAttachment.closed = GetBoolean(map, "closed", false);
|
||||
pathAttachment.constantSpeed = GetBoolean(map, "constantSpeed", true);
|
||||
|
||||
int vertexCount = GetInt(map, "vertexCount", 0);
|
||||
ReadVertices(map, pathAttachment, vertexCount << 1);
|
||||
int vertexCount = GetInt(map, "vertexCount", 0);
|
||||
ReadVertices(map, pathAttachment, vertexCount << 1);
|
||||
|
||||
// potential BOZO see Java impl
|
||||
pathAttachment.lengths = GetFloatArray(map, "lengths", scale);
|
||||
return pathAttachment;
|
||||
}
|
||||
// potential BOZO see Java impl
|
||||
pathAttachment.lengths = GetFloatArray(map, "lengths", scale);
|
||||
return pathAttachment;
|
||||
}
|
||||
case AttachmentType.Point: {
|
||||
PointAttachment point = attachmentLoader.NewPointAttachment(skin, name);
|
||||
if (point == null) return null;
|
||||
point.x = GetFloat(map, "x", 0) * scale;
|
||||
point.y = GetFloat(map, "y", 0) * scale;
|
||||
point.rotation = GetFloat(map, "rotation", 0);
|
||||
PointAttachment point = attachmentLoader.NewPointAttachment(skin, name);
|
||||
if (point == null) return null;
|
||||
point.x = GetFloat(map, "x", 0) * scale;
|
||||
point.y = GetFloat(map, "y", 0) * scale;
|
||||
point.rotation = GetFloat(map, "rotation", 0);
|
||||
|
||||
//string color = GetString(map, "color", null);
|
||||
//if (color != null) point.color = color;
|
||||
return point;
|
||||
}
|
||||
//string color = GetString(map, "color", null);
|
||||
//if (color != null) point.color = color;
|
||||
return point;
|
||||
}
|
||||
case AttachmentType.Clipping: {
|
||||
ClippingAttachment clip = attachmentLoader.NewClippingAttachment(skin, name);
|
||||
if (clip == null) return null;
|
||||
ClippingAttachment clip = attachmentLoader.NewClippingAttachment(skin, name);
|
||||
if (clip == null) return null;
|
||||
|
||||
string end = GetString(map, "end", null);
|
||||
if (end != null) {
|
||||
SlotData slot = skeletonData.FindSlot(end);
|
||||
if (slot == null) throw new Exception("Clipping end slot not found: " + end);
|
||||
clip.EndSlot = slot;
|
||||
}
|
||||
|
||||
ReadVertices(map, clip, GetInt(map, "vertexCount", 0) << 1);
|
||||
|
||||
//string color = GetString(map, "color", null);
|
||||
// if (color != null) clip.color = color;
|
||||
return clip;
|
||||
string end = GetString(map, "end", null);
|
||||
if (end != null) {
|
||||
SlotData slot = skeletonData.FindSlot(end);
|
||||
if (slot == null) throw new Exception("Clipping end slot not found: " + end);
|
||||
clip.EndSlot = slot;
|
||||
}
|
||||
|
||||
ReadVertices(map, clip, GetInt(map, "vertexCount", 0) << 1);
|
||||
|
||||
//string color = GetString(map, "color", null);
|
||||
// if (color != null) clip.color = color;
|
||||
return clip;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -557,7 +557,7 @@ namespace Spine {
|
||||
float g = ToColor(color, 1);
|
||||
float b = ToColor(color, 2);
|
||||
float a = ToColor(color, 3);
|
||||
for (int frame = 0, bezier = 0;; frame++) {
|
||||
for (int frame = 0, bezier = 0; ; frame++) {
|
||||
timeline.SetFrame(frame, time, r, g, b, a);
|
||||
if (!keyMapEnumerator.MoveNext()) {
|
||||
timeline.Shrink(bezier);
|
||||
@ -632,7 +632,7 @@ namespace Spine {
|
||||
keyMapEnumerator.MoveNext();
|
||||
timelines.Add(ReadTimeline(ref keyMapEnumerator, new AlphaTimeline(values.Count, values.Count, slotIndex), 0, 1));
|
||||
|
||||
} else if (timelineName == "rgba2") {
|
||||
} else if (timelineName == "rgba2") {
|
||||
var timeline = new RGBA2Timeline(values.Count, values.Count * 7, slotIndex);
|
||||
|
||||
var keyMapEnumerator = values.GetEnumerator();
|
||||
@ -1127,7 +1127,7 @@ namespace Spine {
|
||||
timeline.SetBezier(bezier, frame, value, time1, value1, cx1, cy1, cx2, cy2, time2, value2);
|
||||
}
|
||||
|
||||
static float[] GetFloatArray(Dictionary<string, Object> map, string name, float scale) {
|
||||
static float[] GetFloatArray (Dictionary<string, Object> map, string name, float scale) {
|
||||
var list = (List<Object>)map[name];
|
||||
var values = new float[list.Count];
|
||||
if (scale == 1) {
|
||||
@ -1140,7 +1140,7 @@ namespace Spine {
|
||||
return values;
|
||||
}
|
||||
|
||||
static int[] GetIntArray(Dictionary<string, Object> map, string name) {
|
||||
static int[] GetIntArray (Dictionary<string, Object> map, string name) {
|
||||
var list = (List<Object>)map[name];
|
||||
var values = new int[list.Count];
|
||||
for (int i = 0, n = list.Count; i < n; i++)
|
||||
@ -1148,27 +1148,27 @@ namespace Spine {
|
||||
return values;
|
||||
}
|
||||
|
||||
static float GetFloat(Dictionary<string, Object> map, string name, float defaultValue) {
|
||||
static float GetFloat (Dictionary<string, Object> map, string name, float defaultValue) {
|
||||
if (!map.ContainsKey(name)) return defaultValue;
|
||||
return (float)map[name];
|
||||
}
|
||||
|
||||
static int GetInt(Dictionary<string, Object> map, string name, int defaultValue) {
|
||||
static int GetInt (Dictionary<string, Object> map, string name, int defaultValue) {
|
||||
if (!map.ContainsKey(name)) return defaultValue;
|
||||
return (int)(float)map[name];
|
||||
}
|
||||
|
||||
static bool GetBoolean(Dictionary<string, Object> map, string name, bool defaultValue) {
|
||||
static bool GetBoolean (Dictionary<string, Object> map, string name, bool defaultValue) {
|
||||
if (!map.ContainsKey(name)) return defaultValue;
|
||||
return (bool)map[name];
|
||||
}
|
||||
|
||||
static string GetString(Dictionary<string, Object> map, string name, string defaultValue) {
|
||||
static string GetString (Dictionary<string, Object> map, string name, string defaultValue) {
|
||||
if (!map.ContainsKey(name)) return defaultValue;
|
||||
return (string)map[name];
|
||||
}
|
||||
|
||||
static float ToColor(string hexString, int colorIndex, int expectedLength = 8) {
|
||||
static float ToColor (string hexString, int colorIndex, int expectedLength = 8) {
|
||||
if (hexString.Length != expectedLength)
|
||||
throw new ArgumentException("Color hexidecimal length must be " + expectedLength + ", recieved: " + hexString, "hexString");
|
||||
return Convert.ToInt32(hexString.Substring(colorIndex * 2, 2), 16) / (float)255;
|
||||
|
||||
@ -28,8 +28,8 @@
|
||||
*****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Spine {
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ namespace Spine {
|
||||
}
|
||||
|
||||
/// <summary>Copy constructor.</summary>
|
||||
public Slot(Slot slot, Bone bone) {
|
||||
public Slot (Slot slot, Bone bone) {
|
||||
if (slot == null) throw new ArgumentNullException("slot", "slot cannot be null.");
|
||||
if (bone == null) throw new ArgumentNullException("bone", "bone cannot be null.");
|
||||
data = slot.data;
|
||||
@ -106,7 +106,7 @@ namespace Spine {
|
||||
/// color tinting.</summary>
|
||||
public float A { get { return a; } set { a = value; } }
|
||||
|
||||
public void ClampColor() {
|
||||
public void ClampColor () {
|
||||
r = MathUtils.Clamp(r, 0, 1);
|
||||
g = MathUtils.Clamp(g, 0, 1);
|
||||
b = MathUtils.Clamp(b, 0, 1);
|
||||
|
||||
@ -62,7 +62,7 @@ namespace Spine {
|
||||
public BlendMode BlendMode { get { return blendMode; } set { blendMode = value; } }
|
||||
|
||||
public SlotData (int index, String name, BoneData boneData) {
|
||||
if (index < 0) throw new ArgumentException ("index must be >= 0.", "index");
|
||||
if (index < 0) throw new ArgumentException("index must be >= 0.", "index");
|
||||
if (name == null) throw new ArgumentNullException("name", "name cannot be null.");
|
||||
if (boneData == null) throw new ArgumentNullException("boneData", "boneData cannot be null.");
|
||||
this.index = index;
|
||||
|
||||
@ -57,7 +57,7 @@ namespace Spine {
|
||||
mixShearY = data.mixShearY;
|
||||
bones = new ExposedList<Bone>();
|
||||
foreach (BoneData boneData in data.bones)
|
||||
bones.Add (skeleton.FindBone(boneData.name));
|
||||
bones.Add(skeleton.FindBone(boneData.name));
|
||||
|
||||
target = skeleton.FindBone(data.target.name);
|
||||
}
|
||||
|
||||
@ -27,10 +27,10 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System;
|
||||
|
||||
namespace Spine {
|
||||
|
||||
@ -40,19 +40,19 @@ namespace Spine {
|
||||
private MouseState lastMouseState;
|
||||
protected Boolean mouseClicked = false;
|
||||
|
||||
public Screen(Example game) {
|
||||
public Screen (Example game) {
|
||||
this.game = game;
|
||||
skeletonRenderer = new SkeletonRenderer(game.GraphicsDevice);
|
||||
skeletonRenderer.PremultipliedAlpha = false;
|
||||
}
|
||||
|
||||
public void UpdateInput() {
|
||||
public void UpdateInput () {
|
||||
MouseState state = Mouse.GetState();
|
||||
mouseClicked = lastMouseState.LeftButton == ButtonState.Pressed && state.LeftButton == ButtonState.Released;
|
||||
lastMouseState = state;
|
||||
}
|
||||
|
||||
public abstract void Render(float deltaTime);
|
||||
public abstract void Render (float deltaTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -63,7 +63,7 @@ namespace Spine {
|
||||
Skeleton skeleton;
|
||||
AnimationState state;
|
||||
|
||||
public RaptorScreen(Example game) : base (game) {
|
||||
public RaptorScreen (Example game) : base(game) {
|
||||
// Load the texture atlas
|
||||
atlas = new Atlas("data/raptor.atlas", new XnaTextureLoader(game.GraphicsDevice));
|
||||
|
||||
@ -85,7 +85,7 @@ namespace Spine {
|
||||
state.SetAnimation(0, "walk", true);
|
||||
}
|
||||
|
||||
public override void Render(float deltaTime) {
|
||||
public override void Render (float deltaTime) {
|
||||
// Update the animation state and apply the animations
|
||||
// to the skeleton
|
||||
state.Update(deltaTime);
|
||||
@ -116,7 +116,7 @@ namespace Spine {
|
||||
Skeleton skeleton;
|
||||
AnimationState state;
|
||||
|
||||
public TankScreen(Example game) : base(game) {
|
||||
public TankScreen (Example game) : base(game) {
|
||||
// Instantiate and configure the two color tinting effect and
|
||||
// assign it to the skeleton renderer
|
||||
var twoColorTintEffect = game.Content.Load<Effect>("Content\\SpineEffect");
|
||||
@ -140,7 +140,7 @@ namespace Spine {
|
||||
state.SetAnimation(0, "shoot", true);
|
||||
}
|
||||
|
||||
public override void Render(float deltaTime) {
|
||||
public override void Render (float deltaTime) {
|
||||
state.Update(deltaTime);
|
||||
state.Apply(skeleton);
|
||||
|
||||
@ -169,7 +169,7 @@ namespace Spine {
|
||||
Skeleton skeleton;
|
||||
AnimationState state;
|
||||
|
||||
public SpineboyScreen(Example game) : base(game) {
|
||||
public SpineboyScreen (Example game) : base(game) {
|
||||
atlas = new Atlas("data/spineboy.atlas", new XnaTextureLoader(game.GraphicsDevice));
|
||||
|
||||
SkeletonBinary binary = new SkeletonBinary(atlas);
|
||||
@ -197,7 +197,7 @@ namespace Spine {
|
||||
state.AddAnimation(0, "run", true, 0);
|
||||
}
|
||||
|
||||
public override void Render(float deltaTime) {
|
||||
public override void Render (float deltaTime) {
|
||||
state.Update(deltaTime);
|
||||
state.Apply(skeleton);
|
||||
skeleton.UpdateWorldTransform();
|
||||
@ -223,7 +223,7 @@ namespace Spine {
|
||||
Skeleton skeleton;
|
||||
AnimationState state;
|
||||
|
||||
public MixAndMatchScreen(Example game) : base(game) {
|
||||
public MixAndMatchScreen (Example game) : base(game) {
|
||||
atlas = new Atlas("data/mix-and-match.atlas", new XnaTextureLoader(game.GraphicsDevice));
|
||||
|
||||
SkeletonJson json = new SkeletonJson(atlas);
|
||||
@ -256,7 +256,7 @@ namespace Spine {
|
||||
skeleton.SetSkin(mixAndMatchSkin);
|
||||
}
|
||||
|
||||
public override void Render(float deltaTime) {
|
||||
public override void Render (float deltaTime) {
|
||||
state.Update(deltaTime);
|
||||
state.Apply(skeleton);
|
||||
skeleton.UpdateWorldTransform();
|
||||
@ -276,7 +276,7 @@ namespace Spine {
|
||||
GraphicsDeviceManager graphics;
|
||||
public Screen currentScreen;
|
||||
|
||||
public Example() {
|
||||
public Example () {
|
||||
IsMouseVisible = true;
|
||||
|
||||
graphics = new GraphicsDeviceManager(this);
|
||||
@ -285,15 +285,15 @@ namespace Spine {
|
||||
graphics.PreferredBackBufferHeight = 600;
|
||||
}
|
||||
|
||||
protected override void LoadContent() {
|
||||
protected override void LoadContent () {
|
||||
currentScreen = new MixAndMatchScreen(this);
|
||||
}
|
||||
|
||||
protected override void Update(GameTime gameTime) {
|
||||
protected override void Update (GameTime gameTime) {
|
||||
currentScreen.UpdateInput();
|
||||
}
|
||||
|
||||
protected override void Draw(GameTime gameTime) {
|
||||
protected override void Draw (GameTime gameTime) {
|
||||
currentScreen.Render((float)(gameTime.ElapsedGameTime.TotalMilliseconds / 1000.0));
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,11 +30,11 @@
|
||||
using System;
|
||||
|
||||
namespace Spine {
|
||||
static class ExampleProgram {
|
||||
static void Main (string[] args) {
|
||||
using (Example game = new Example()) {
|
||||
game.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
static class ExampleProgram {
|
||||
static void Main (string[] args) {
|
||||
using (Example game = new Example()) {
|
||||
game.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,14 +27,12 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using Spine;
|
||||
using Spine.Unity;
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class SpineAnimationTesterTool : MonoBehaviour, IHasSkeletonDataAsset, IHasSkeletonComponent {
|
||||
@ -48,7 +46,7 @@ namespace Spine.Unity.Examples {
|
||||
|
||||
public bool useOverrideAttachmentThreshold = true;
|
||||
|
||||
[Range(0f,1f)]
|
||||
[Range(0f, 1f)]
|
||||
public float attachmentThreshold = 0.5f;
|
||||
|
||||
public bool useOverrideDrawOrderThreshold;
|
||||
|
||||
@ -56,7 +56,7 @@ namespace Spine.Unity.Examples {
|
||||
if (currentHealth > 0) {
|
||||
spineboy.AnimationState.SetAnimation(0, hit, false);
|
||||
spineboy.AnimationState.AddAnimation(0, idle, true, 0);
|
||||
gauge.fillPercent = (float)currentHealth/(float)maxHealth;
|
||||
gauge.fillPercent = (float)currentHealth / (float)maxHealth;
|
||||
onAttack.Invoke();
|
||||
} else {
|
||||
if (currentHealth >= 0) {
|
||||
|
||||
@ -29,9 +29,9 @@
|
||||
|
||||
// Contributed by: Mitch Thompson
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using Spine.Unity;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class FootSoldierExample : MonoBehaviour {
|
||||
@ -81,7 +81,7 @@ namespace Spine.Unity.Examples {
|
||||
skeletonAnimation.AnimationName = moveAnimation;
|
||||
skeletonAnimation.Skeleton.ScaleX = 1;
|
||||
transform.Translate(moveSpeed * Time.deltaTime, 0, 0);
|
||||
} else if(Input.GetKey(leftKey)) {
|
||||
} else if (Input.GetKey(leftKey)) {
|
||||
skeletonAnimation.AnimationName = moveAnimation;
|
||||
skeletonAnimation.Skeleton.ScaleX = -1;
|
||||
transform.Translate(-moveSpeed * Time.deltaTime, 0, 0);
|
||||
@ -91,7 +91,7 @@ namespace Spine.Unity.Examples {
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator Blink() {
|
||||
IEnumerator Blink () {
|
||||
while (true) {
|
||||
yield return new WaitForSeconds(Random.Range(0.25f, 3f));
|
||||
skeletonAnimation.Skeleton.SetAttachment(eyesSlot, blinkAttachment);
|
||||
|
||||
@ -27,9 +27,9 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using Spine.Unity;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
@ -188,29 +188,29 @@ namespace Spine.Unity.Examples {
|
||||
// When the state changes, notify the animation handle of the new state.
|
||||
string stateName = null;
|
||||
switch (currentState) {
|
||||
case CharacterState.Idle:
|
||||
stateName = "idle";
|
||||
break;
|
||||
case CharacterState.Walk:
|
||||
stateName = "walk";
|
||||
break;
|
||||
case CharacterState.Run:
|
||||
stateName = "run";
|
||||
break;
|
||||
case CharacterState.Crouch:
|
||||
stateName = "crouch";
|
||||
break;
|
||||
case CharacterState.Rise:
|
||||
stateName = "rise";
|
||||
break;
|
||||
case CharacterState.Fall:
|
||||
stateName = "fall";
|
||||
break;
|
||||
case CharacterState.Attack:
|
||||
stateName = "attack";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case CharacterState.Idle:
|
||||
stateName = "idle";
|
||||
break;
|
||||
case CharacterState.Walk:
|
||||
stateName = "walk";
|
||||
break;
|
||||
case CharacterState.Run:
|
||||
stateName = "run";
|
||||
break;
|
||||
case CharacterState.Crouch:
|
||||
stateName = "crouch";
|
||||
break;
|
||||
case CharacterState.Rise:
|
||||
stateName = "rise";
|
||||
break;
|
||||
case CharacterState.Fall:
|
||||
stateName = "fall";
|
||||
break;
|
||||
case CharacterState.Attack:
|
||||
stateName = "attack";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
animationHandle.PlayAnimationForState(stateName, 0);
|
||||
|
||||
@ -27,9 +27,9 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using Spine.Unity;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class Raptor : MonoBehaviour {
|
||||
|
||||
@ -27,9 +27,9 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using Spine.Unity;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class SpineBeginnerTwo : MonoBehaviour {
|
||||
@ -92,7 +92,7 @@ namespace Spine.Unity.Examples {
|
||||
spineAnimationState.AddAnimation(0, idleAnimationName, true, 0);
|
||||
yield return new WaitForSeconds(1f);
|
||||
|
||||
skeleton.ScaleX = -1; // skeleton allows you to flip the skeleton.
|
||||
skeleton.ScaleX = -1; // skeleton allows you to flip the skeleton.
|
||||
spineAnimationState.SetAnimation(0, idleTurnAnimationName, false);
|
||||
spineAnimationState.AddAnimation(0, idleAnimationName, true, 0);
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
@ -27,9 +27,9 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using Spine.Unity;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class SpineBlinkPlayer : MonoBehaviour {
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class SpineboyBeginnerInput : MonoBehaviour {
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
[SelectionBase]
|
||||
@ -46,7 +46,7 @@ namespace Spine.Unity.Examples {
|
||||
#endregion
|
||||
|
||||
float lastShootTime;
|
||||
public event System.Action ShootEvent; // Lets other scripts know when Spineboy is shooting. Check C# Documentation to learn more about events and delegates.
|
||||
public event System.Action ShootEvent; // Lets other scripts know when Spineboy is shooting. Check C# Documentation to learn more about events and delegates.
|
||||
public event System.Action StartAimEvent; // Lets other scripts know when Spineboy is aiming.
|
||||
public event System.Action StopAimEvent; // Lets other scripts know when Spineboy is no longer aiming.
|
||||
|
||||
@ -60,7 +60,7 @@ namespace Spine.Unity.Examples {
|
||||
|
||||
if (currentTime - lastShootTime > shootInterval) {
|
||||
lastShootTime = currentTime;
|
||||
if (ShootEvent != null) ShootEvent(); // Fire the "ShootEvent" event.
|
||||
if (ShootEvent != null) ShootEvent(); // Fire the "ShootEvent" event.
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ namespace Spine.Unity.Examples {
|
||||
#endregion
|
||||
|
||||
IEnumerator JumpRoutine () {
|
||||
if (state == SpineBeginnerBodyState.Jumping) yield break; // Don't jump when already jumping.
|
||||
if (state == SpineBeginnerBodyState.Jumping) yield break; // Don't jump when already jumping.
|
||||
|
||||
state = SpineBeginnerBodyState.Jumping;
|
||||
|
||||
|
||||
@ -27,9 +27,9 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using Spine.Unity;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class SpineboyBeginnerView : MonoBehaviour {
|
||||
@ -70,7 +70,7 @@ namespace Spine.Unity.Examples {
|
||||
if (skeletonAnimation == null) return;
|
||||
if (model == null) return;
|
||||
|
||||
if ((skeletonAnimation.skeleton.ScaleX < 0) != model.facingLeft) { // Detect changes in model.facingLeft
|
||||
if ((skeletonAnimation.skeleton.ScaleX < 0) != model.facingLeft) { // Detect changes in model.facingLeft
|
||||
Turn(model.facingLeft);
|
||||
}
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ namespace Spine.Unity.Examples {
|
||||
|
||||
public SkeletonAnimation skeletonAnimation;
|
||||
|
||||
[SpineBone(dataField:"skeletonAnimation")]
|
||||
[SpineBone(dataField: "skeletonAnimation")]
|
||||
public string boneName;
|
||||
public Camera cam;
|
||||
|
||||
|
||||
@ -27,9 +27,9 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using Spine;
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class Goblins : MonoBehaviour {
|
||||
|
||||
@ -37,8 +37,8 @@ public class HurtFlashEffect : MonoBehaviour {
|
||||
|
||||
public int flashCount = DefaultFlashCount;
|
||||
public Color flashColor = Color.white;
|
||||
[Range(1f/120f, 1f/15f)]
|
||||
public float interval = 1f/60f;
|
||||
[Range(1f / 120f, 1f / 15f)]
|
||||
public float interval = 1f / 60f;
|
||||
public string fillPhaseProperty = "_FillPhase";
|
||||
public string fillColorProperty = "_FillColor";
|
||||
|
||||
|
||||
@ -27,13 +27,12 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using Spine;
|
||||
using Spine.Unity;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using Spine;
|
||||
using Spine.Unity;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
//[CreateAssetMenu(menuName = "Spine/SkeletonData Modifiers/Animation Match", order = 200)]
|
||||
|
||||
@ -27,12 +27,11 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using Spine.Unity.AttachmentTools;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using Spine.Unity.AttachmentTools;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class EquipSystemExample : MonoBehaviour, IHasSkeletonDataAsset {
|
||||
|
||||
@ -54,7 +53,7 @@ namespace Spine.Unity.Examples {
|
||||
public string slot;
|
||||
[SpineSkin]
|
||||
public string templateSkin;
|
||||
[SpineAttachment(skinField:"templateSkin")]
|
||||
[SpineAttachment(skinField: "templateSkin")]
|
||||
public string templateAttachment;
|
||||
}
|
||||
|
||||
|
||||
@ -27,12 +27,11 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using Spine.Unity.AttachmentTools;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using Spine.Unity.AttachmentTools;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class EquipsVisualsComponentExample : MonoBehaviour {
|
||||
|
||||
@ -79,7 +78,7 @@ namespace Spine.Unity.Examples {
|
||||
if (runtimeAtlas)
|
||||
Destroy(runtimeAtlas);
|
||||
var repackedSkin = collectedSkin.GetRepackedSkin("Repacked skin", skeletonAnimation.SkeletonDataAsset.atlasAssets[0].PrimaryMaterial,
|
||||
out runtimeMaterial, out runtimeAtlas, maxAtlasSize : 1024, clearCache: false);
|
||||
out runtimeMaterial, out runtimeAtlas, maxAtlasSize: 1024, clearCache: false);
|
||||
collectedSkin.Clear();
|
||||
|
||||
// You can optionally clear the textures cache after each ore multiple repack operations are done.
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
@ -37,7 +37,7 @@ namespace Spine.Unity.Examples {
|
||||
public SkeletonDataAsset skeletonDataAsset;
|
||||
public MixAndMatchSkinsExample skinsSystem;
|
||||
|
||||
[SpineSkin(dataField:"skeletonDataAsset")] public string itemSkin;
|
||||
[SpineSkin(dataField: "skeletonDataAsset")] public string itemSkin;
|
||||
public MixAndMatchSkinsExample.ItemType itemType;
|
||||
|
||||
void Start () {
|
||||
|
||||
@ -27,9 +27,9 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using Spine.Unity.AttachmentTools;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Spine.Unity.AttachmentTools;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
@ -77,7 +77,7 @@ namespace Spine.Unity.Examples {
|
||||
UpdateCombinedSkin();
|
||||
}
|
||||
|
||||
public void NextHairSkin() {
|
||||
public void NextHairSkin () {
|
||||
activeHairIndex = (activeHairIndex + 1) % hairSkins.Length;
|
||||
UpdateCharacterSkin();
|
||||
UpdateCombinedSkin();
|
||||
@ -113,22 +113,22 @@ namespace Spine.Unity.Examples {
|
||||
UpdateCombinedSkin();
|
||||
}
|
||||
|
||||
public void Equip(string itemSkin, ItemType itemType) {
|
||||
public void Equip (string itemSkin, ItemType itemType) {
|
||||
switch (itemType) {
|
||||
case ItemType.Cloth:
|
||||
clothesSkin = itemSkin;
|
||||
break;
|
||||
case ItemType.Pants:
|
||||
pantsSkin = itemSkin;
|
||||
break;
|
||||
case ItemType.Bag:
|
||||
bagSkin = itemSkin;
|
||||
break;
|
||||
case ItemType.Hat:
|
||||
hatSkin = itemSkin;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case ItemType.Cloth:
|
||||
clothesSkin = itemSkin;
|
||||
break;
|
||||
case ItemType.Pants:
|
||||
pantsSkin = itemSkin;
|
||||
break;
|
||||
case ItemType.Bag:
|
||||
bagSkin = itemSkin;
|
||||
break;
|
||||
case ItemType.Hat:
|
||||
hatSkin = itemSkin;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
UpdateCombinedSkin();
|
||||
}
|
||||
|
||||
@ -27,9 +27,9 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using Spine.Unity.AttachmentTools;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
|
||||
@ -27,9 +27,9 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using Spine.Unity.AttachmentTools;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
|
||||
@ -27,16 +27,16 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using Spine.Unity;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class RaggedySpineboy : MonoBehaviour {
|
||||
|
||||
public LayerMask groundMask;
|
||||
public float restoreDuration = 0.5f;
|
||||
public Vector2 launchVelocity = new Vector2(50,100);
|
||||
public Vector2 launchVelocity = new Vector2(50, 100);
|
||||
|
||||
Spine.Unity.Examples.SkeletonRagdoll2D ragdoll;
|
||||
Collider2D naturalCollider;
|
||||
|
||||
@ -27,9 +27,9 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using Spine;
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class BoneLocalOverride : MonoBehaviour {
|
||||
@ -50,7 +50,7 @@ namespace Spine.Unity.Examples {
|
||||
ISkeletonAnimation spineComponent;
|
||||
Bone bone;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_EDITOR
|
||||
void OnValidate () {
|
||||
if (Application.isPlaying) return;
|
||||
spineComponent = spineComponent ?? GetComponent<ISkeletonAnimation>();
|
||||
@ -58,14 +58,14 @@ namespace Spine.Unity.Examples {
|
||||
if (bone != null) bone.SetToSetupPose();
|
||||
OverrideLocal(spineComponent);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void Awake () {
|
||||
spineComponent = GetComponent<ISkeletonAnimation>();
|
||||
if (spineComponent == null) { this.enabled = false; return; }
|
||||
spineComponent.UpdateLocal += OverrideLocal;
|
||||
|
||||
if (bone == null) { this.enabled = false; return; }
|
||||
if (bone == null) { this.enabled = false; return; }
|
||||
}
|
||||
|
||||
void OverrideLocal (ISkeletonAnimation animated) {
|
||||
|
||||
@ -27,10 +27,10 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using Spine.Unity.AttachmentTools;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Spine.Unity.AttachmentTools;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class CombinedSkin : MonoBehaviour {
|
||||
|
||||
@ -29,8 +29,8 @@
|
||||
|
||||
// Contributed by: Mitch Thompson
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
@ -44,7 +44,7 @@ namespace Spine.Unity.Examples {
|
||||
public bool ghostingEnabled = true;
|
||||
[Tooltip("The time between invididual ghost pieces being spawned.")]
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("spawnRate")]
|
||||
public float spawnInterval = 1f/30f;
|
||||
public float spawnInterval = 1f / 30f;
|
||||
[Tooltip("Maximum number of ghosts that can exist at a time. If the fade speed is not fast enough, the oldest ghost will immediately disappear to enforce the maximum number.")]
|
||||
public int maximumGhosts = 10;
|
||||
public float fadeSpeed = 10;
|
||||
|
||||
@ -29,8 +29,8 @@
|
||||
|
||||
// Contributed by: Mitch Thompson
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class SkeletonGhostRenderer : MonoBehaviour {
|
||||
|
||||
@ -27,10 +27,10 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using Spine;
|
||||
using Spine.Unity.AttachmentTools;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
/// <summary>
|
||||
|
||||
@ -29,9 +29,9 @@
|
||||
|
||||
// Original Contribution by: Mitch Thompson
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using Spine.Unity.AttachmentTools;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class SpriteAttacher : MonoBehaviour {
|
||||
@ -45,7 +45,7 @@ namespace Spine.Unity.Examples {
|
||||
[SpineSlot] public string slot;
|
||||
#endregion
|
||||
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_EDITOR
|
||||
void OnValidate () {
|
||||
var skeletonComponent = GetComponent<ISkeletonComponent>();
|
||||
var skeletonRenderer = skeletonComponent as SkeletonRenderer;
|
||||
@ -70,7 +70,7 @@ namespace Spine.Unity.Examples {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
RegionAttachment attachment;
|
||||
Slot spineSlot;
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
@ -38,7 +38,7 @@ namespace Spine.Unity.Examples {
|
||||
public Material materialWithoutOutline;
|
||||
public Material materialWithOutline;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_EDITOR
|
||||
void Reset () {
|
||||
skeletonGraphic = GetComponent<SkeletonGraphic>();
|
||||
|
||||
@ -51,7 +51,7 @@ namespace Spine.Unity.Examples {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void OnEnable () {
|
||||
if (skeletonGraphic == null)
|
||||
@ -62,7 +62,7 @@ namespace Spine.Unity.Examples {
|
||||
skeletonGraphic.material = materialWithOutline;
|
||||
}
|
||||
|
||||
public void DisableOutlineRendering () {
|
||||
public void DisableOutlineRendering () {
|
||||
skeletonGraphic.material = materialWithoutOutline;
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,8 +31,8 @@
|
||||
#define NEW_PREFAB_SYSTEM
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
@ -42,8 +42,7 @@ namespace Spine.Unity.Examples {
|
||||
[ExecuteInEditMode]
|
||||
#endif
|
||||
[RequireComponent(typeof(MeshRenderer)), RequireComponent(typeof(MeshFilter))]
|
||||
public class RenderExistingMesh : MonoBehaviour
|
||||
{
|
||||
public class RenderExistingMesh : MonoBehaviour {
|
||||
public MeshRenderer referenceRenderer;
|
||||
|
||||
bool updateViaSkeletonCallback = false;
|
||||
@ -101,21 +100,21 @@ namespace Spine.Unity.Examples {
|
||||
InitializeDict();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_EDITOR
|
||||
private void Update () {
|
||||
if (!Application.isPlaying) {
|
||||
InitializeDict();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void LateUpdate () {
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying) {
|
||||
UpdateMaterials();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (updateViaSkeletonCallback)
|
||||
return;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
using UnityEngine;
|
||||
using Spine.Unity;
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
@ -38,7 +38,7 @@ namespace Spine.Unity.Examples {
|
||||
rootMotion.rootMotionTranslateYPerX = 0;
|
||||
}
|
||||
|
||||
void AdjustDelta() {
|
||||
void AdjustDelta () {
|
||||
Vector3 toTarget = targetPosition.position - this.transform.position;
|
||||
rootMotion.AdjustRootMotionToDistance(toTarget, trackIndex, adjustX, adjustY,
|
||||
minScaleX, maxScaleX, minScaleY, maxScaleY,
|
||||
|
||||
@ -40,8 +40,7 @@ namespace Spine.Unity.Examples {
|
||||
/// will be overwritten by the provided value.
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent]
|
||||
public class SetRigidbodySolverIterations : MonoBehaviour
|
||||
{
|
||||
public class SetRigidbodySolverIterations : MonoBehaviour {
|
||||
public int solverIterations = 30;
|
||||
|
||||
void Awake () {
|
||||
|
||||
@ -27,13 +27,12 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using Spine;
|
||||
using Spine.Unity;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using Spine;
|
||||
using Spine.Unity;
|
||||
|
||||
namespace Spine.Unity {
|
||||
|
||||
using Animation = Spine.Animation;
|
||||
|
||||
@ -27,10 +27,10 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Spine;
|
||||
using Spine.Unity;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Prototyping {
|
||||
/// <summary>
|
||||
@ -46,7 +46,7 @@ namespace Spine.Unity.Prototyping {
|
||||
public Color color = Color.white;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_EDITOR
|
||||
void OnValidate () {
|
||||
var skeletonComponent = GetComponent<ISkeletonComponent>();
|
||||
if (skeletonComponent != null) {
|
||||
@ -58,7 +58,7 @@ namespace Spine.Unity.Prototyping {
|
||||
}
|
||||
ApplySettings();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void Start () {
|
||||
ApplySettings();
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
|
||||
public class SkeletonGraphicPlayAnimationAtEvent : MonoBehaviour {
|
||||
|
||||
|
||||
@ -29,9 +29,9 @@
|
||||
|
||||
// Contributed by: Mitch Thompson
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class SkeletonRagdoll2DInspector {}
|
||||
public class SkeletonRagdoll2DInspector { }
|
||||
}
|
||||
|
||||
@ -29,8 +29,8 @@
|
||||
|
||||
// Contributed by: Mitch Thompson
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
|
||||
@ -29,9 +29,9 @@
|
||||
|
||||
// Contributed by: Mitch Thompson
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
[RequireComponent(typeof(SkeletonRenderer))]
|
||||
@ -437,7 +437,7 @@ namespace Spine.Unity.Examples {
|
||||
return colliders;
|
||||
}
|
||||
|
||||
public class LayerFieldAttribute : PropertyAttribute {}
|
||||
public class LayerFieldAttribute : PropertyAttribute { }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -33,9 +33,9 @@
|
||||
#define HINGE_JOINT_NEW_BEHAVIOUR
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
[RequireComponent(typeof(SkeletonRenderer))]
|
||||
@ -174,7 +174,7 @@ namespace Spine.Unity.Examples {
|
||||
|
||||
joint.GetComponent<Rigidbody2D>().mass = joint.connectedBody.mass * massFalloffFactor;
|
||||
|
||||
#if HINGE_JOINT_NEW_BEHAVIOUR
|
||||
#if HINGE_JOINT_NEW_BEHAVIOUR
|
||||
float referenceAngle = (rbParent.transform.eulerAngles.z - t.eulerAngles.z + 360f) % 360f;
|
||||
float minAngle = referenceAngle - rotationLimit;
|
||||
float maxAngle = referenceAngle + rotationLimit;
|
||||
@ -182,10 +182,10 @@ namespace Spine.Unity.Examples {
|
||||
minAngle -= 360f;
|
||||
maxAngle -= 360f;
|
||||
}
|
||||
#else
|
||||
float minAngle = - rotationLimit;
|
||||
#else
|
||||
float minAngle = -rotationLimit;
|
||||
float maxAngle = rotationLimit;
|
||||
#endif
|
||||
#endif
|
||||
joint.limits = new JointAngleLimits2D {
|
||||
min = minAngle,
|
||||
max = maxAngle
|
||||
@ -457,7 +457,7 @@ namespace Spine.Unity.Examples {
|
||||
return new Vector3(flipX ? -1f : 1f, flipY ? -1f : 1f, 1f);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_EDITOR
|
||||
void OnDrawGizmosSelected () {
|
||||
if (isActive) {
|
||||
Gizmos.DrawWireSphere(transform.position, thickness * 1.2f);
|
||||
@ -466,7 +466,7 @@ namespace Spine.Unity.Examples {
|
||||
Gizmos.DrawWireSphere(newTransformPos, thickness * 1.2f);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class SkeletonUtilityEyeConstraint : SkeletonUtilityConstraint {
|
||||
|
||||
@ -35,11 +35,11 @@ using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
#if NEW_PREFAB_SYSTEM
|
||||
#if NEW_PREFAB_SYSTEM
|
||||
[ExecuteAlways]
|
||||
#else
|
||||
#else
|
||||
[ExecuteInEditMode]
|
||||
#endif
|
||||
#endif
|
||||
[RequireComponent(typeof(SkeletonUtilityBone))]
|
||||
public class SkeletonUtilityGroundConstraint : SkeletonUtilityConstraint {
|
||||
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@ namespace Spine.Unity.Prototyping {
|
||||
var state = animationStateComponent.AnimationState;
|
||||
foreach (var ep in events) {
|
||||
var eventData = skeletonData.FindEvent(ep.spineEvent);
|
||||
ep.eventDelegate = ep.eventDelegate ?? delegate(TrackEntry trackEntry, Event e) { if (e.Data == eventData) ep.unityHandler.Invoke(); };
|
||||
ep.eventDelegate = ep.eventDelegate ?? delegate (TrackEntry trackEntry, Event e) { if (e.Data == eventData) ep.unityHandler.Invoke(); };
|
||||
state.Event += ep.eventDelegate;
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ namespace Spine.Unity.Examples {
|
||||
[Range(0, 100)]
|
||||
public int count = 20;
|
||||
|
||||
[SpineAnimation(dataField:"skeletonDataAsset")]
|
||||
[SpineAnimation(dataField: "skeletonDataAsset")]
|
||||
public string startingAnimation;
|
||||
|
||||
IEnumerator Start () {
|
||||
@ -51,7 +51,7 @@ namespace Spine.Unity.Examples {
|
||||
var sa = SkeletonAnimation.NewSkeletonAnimationGameObject(skeletonDataAsset); // Spawn a new SkeletonAnimation GameObject.
|
||||
DoExtraStuff(sa, spineAnimation); // optional stuff for fun.
|
||||
sa.gameObject.name = i.ToString();
|
||||
yield return new WaitForSeconds(1f/8f);
|
||||
yield return new WaitForSeconds(1f / 8f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
[ExecuteInEditMode]
|
||||
@ -36,7 +36,7 @@ namespace Spine.Unity.Examples {
|
||||
public class SpineGauge : MonoBehaviour {
|
||||
|
||||
#region Inspector
|
||||
[Range(0,1)]
|
||||
[Range(0, 1)]
|
||||
public float fillPercent = 0;
|
||||
public AnimationReferenceAsset fillAnimation;
|
||||
#endregion
|
||||
|
||||
@ -27,9 +27,9 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using Spine;
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class Spineboy : MonoBehaviour {
|
||||
@ -39,10 +39,10 @@ namespace Spine.Unity.Examples {
|
||||
skeletonAnimation = GetComponent<SkeletonAnimation>(); // Get the SkeletonAnimation component for the GameObject this script is attached to.
|
||||
var animationState = skeletonAnimation.AnimationState;
|
||||
|
||||
animationState.Event += HandleEvent;; // Call our method any time an animation fires an event.
|
||||
animationState.Event += HandleEvent; ; // Call our method any time an animation fires an event.
|
||||
animationState.End += (entry) => Debug.Log("start: " + entry.TrackIndex); // A lambda can be used for the callback instead of a method.
|
||||
|
||||
animationState.AddAnimation(0, "jump", false, 2); // Queue jump to be played on track 0 two seconds after the starting animation.
|
||||
animationState.AddAnimation(0, "jump", false, 2); // Queue jump to be played on track 0 two seconds after the starting animation.
|
||||
animationState.AddAnimation(0, "run", true, 0); // Queue walk to be looped on track 0 after the jump animation.
|
||||
}
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ namespace Spine.Unity.Examples {
|
||||
[SpineSlot]
|
||||
public string eyeSlotName, mouthSlotName;
|
||||
|
||||
[SpineAttachment(slotField:"eyeSlotName")]
|
||||
[SpineAttachment(slotField: "eyeSlotName")]
|
||||
public string shockEyeName, normalEyeName;
|
||||
|
||||
[SpineAttachment(slotField: "mouthSlotName")]
|
||||
|
||||
@ -27,18 +27,17 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using Spine;
|
||||
using Spine.Unity;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using Spine;
|
||||
using Spine.Unity;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class SpineboyFootplanter : MonoBehaviour {
|
||||
|
||||
public float timeScale = 0.5f;
|
||||
[SpineBone] public string nearBoneName, farBoneName;
|
||||
[SpineBone] public string nearBoneName, farBoneName;
|
||||
|
||||
[Header("Settings")]
|
||||
public Vector2 footSize;
|
||||
@ -147,7 +146,7 @@ namespace Spine.Unity.Examples {
|
||||
|
||||
// Default starting positions.
|
||||
nearFoot.worldPos = tpos;
|
||||
nearFoot.worldPos .x -= comfyDistance;
|
||||
nearFoot.worldPos.x -= comfyDistance;
|
||||
nearFoot.worldPosPrev = nearFoot.worldPosNext = nearFoot.worldPos;
|
||||
|
||||
farFoot.worldPos = tpos;
|
||||
|
||||
@ -27,11 +27,10 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using Spine.Unity;
|
||||
|
||||
using Spine.Unity.Examples;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class SpineboyPole : MonoBehaviour {
|
||||
|
||||
@ -27,11 +27,10 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using Spine.Unity;
|
||||
|
||||
using Spine.Unity.Examples;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class SpineboyPoleGraphic : MonoBehaviour {
|
||||
|
||||
@ -27,13 +27,12 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
using System.Reflection;
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
using Editor = UnityEditor.Editor;
|
||||
|
||||
@ -29,23 +29,22 @@
|
||||
|
||||
#define SPINE_SKELETON_MECANIM
|
||||
|
||||
#if (UNITY_2017_4 || UNITY_2018_1_OR_NEWER )
|
||||
#define SPINE_UNITY_2018_PREVIEW_API
|
||||
#endif
|
||||
#if (UNITY_2017_4 || UNITY_2018_1_OR_NEWER)
|
||||
#define SPINE_UNITY_2018_PREVIEW_API
|
||||
#endif
|
||||
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using CompatibilityProblemInfo = Spine.Unity.SkeletonDataCompatibility.CompatibilityProblemInfo;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
using Animation = Spine.Animation;
|
||||
using Event = UnityEngine.Event;
|
||||
using Icons = SpineEditorUtilities.Icons;
|
||||
using Animation = Spine.Animation;
|
||||
|
||||
[CustomEditor(typeof(SkeletonDataAsset)), CanEditMultipleObjects]
|
||||
public class SkeletonDataAssetInspector : UnityEditor.Editor {
|
||||
@ -57,14 +56,14 @@ namespace Spine.Unity.Editor {
|
||||
SerializedProperty atlasAssets, skeletonJSON, scale, fromAnimation, toAnimation, duration, defaultMix;
|
||||
SerializedProperty skeletonDataModifiers;
|
||||
SerializedProperty blendModeMaterials;
|
||||
#if SPINE_TK2D
|
||||
#if SPINE_TK2D
|
||||
SerializedProperty spriteCollection;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if SPINE_SKELETON_MECANIM
|
||||
#if SPINE_SKELETON_MECANIM
|
||||
static bool isMecanimExpanded = false;
|
||||
SerializedProperty controller;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
SkeletonDataAsset targetSkeletonDataAsset;
|
||||
SkeletonData targetSkeletonData;
|
||||
@ -117,17 +116,17 @@ namespace Spine.Unity.Editor {
|
||||
skeletonDataModifiers = serializedObject.FindProperty("skeletonDataModifiers");
|
||||
blendModeMaterials = serializedObject.FindProperty("blendModeMaterials");
|
||||
|
||||
#if SPINE_SKELETON_MECANIM
|
||||
#if SPINE_SKELETON_MECANIM
|
||||
controller = serializedObject.FindProperty("controller");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if SPINE_TK2D
|
||||
#if SPINE_TK2D
|
||||
if (newAtlasAssets) atlasAssets.isExpanded = false;
|
||||
spriteCollection = serializedObject.FindProperty("spriteCollection");
|
||||
#else
|
||||
#else
|
||||
// Analysis disable once ConvertIfToOrExpression
|
||||
if (newAtlasAssets) atlasAssets.isExpanded = true;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// This handles the case where the managed editor assembly is unloaded before recompilation when code changes.
|
||||
AppDomain.CurrentDomain.DomainUnload -= OnDomainUnload;
|
||||
@ -234,15 +233,15 @@ namespace Spine.Unity.Editor {
|
||||
DrawUnityTools();
|
||||
|
||||
} else {
|
||||
#if !SPINE_TK2D
|
||||
#if !SPINE_TK2D
|
||||
// Draw Reimport Button
|
||||
using (new EditorGUI.DisabledGroupScope(skeletonJSON.objectReferenceValue == null)) {
|
||||
if (GUILayout.Button(SpineInspectorUtility.TempContent("Attempt Reimport", Icons.warning)))
|
||||
DoReimport();
|
||||
}
|
||||
#else
|
||||
#else
|
||||
EditorGUILayout.HelpBox("Couldn't load SkeletonData.", MessageType.Error);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
DrawWarningList();
|
||||
}
|
||||
@ -295,15 +294,15 @@ namespace Spine.Unity.Editor {
|
||||
// Texture source field.
|
||||
using (new SpineInspectorUtility.BoxScope()) {
|
||||
EditorGUILayout.LabelField("Atlas", EditorStyles.boldLabel);
|
||||
#if !SPINE_TK2D
|
||||
#if !SPINE_TK2D
|
||||
EditorGUILayout.PropertyField(atlasAssets, true);
|
||||
#else
|
||||
#else
|
||||
using (new EditorGUI.DisabledGroupScope(spriteCollection.objectReferenceValue != null)) {
|
||||
EditorGUILayout.PropertyField(atlasAssets, true);
|
||||
}
|
||||
EditorGUILayout.LabelField("spine-tk2d", EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(spriteCollection, true);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
// Mix settings.
|
||||
@ -362,15 +361,15 @@ namespace Spine.Unity.Editor {
|
||||
|
||||
void DrawAtlasAssetsFields () {
|
||||
EditorGUILayout.LabelField("Atlas", EditorStyles.boldLabel);
|
||||
#if !SPINE_TK2D
|
||||
#if !SPINE_TK2D
|
||||
EditorGUILayout.PropertyField(atlasAssets, true);
|
||||
#else
|
||||
#else
|
||||
using (new EditorGUI.DisabledGroupScope(spriteCollection.objectReferenceValue != null)) {
|
||||
EditorGUILayout.PropertyField(atlasAssets, true);
|
||||
}
|
||||
EditorGUILayout.LabelField("spine-tk2d", EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(spriteCollection, true);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (atlasAssets.arraySize == 0)
|
||||
EditorGUILayout.HelpBox("AtlasAssets array is empty. Skeleton's attachments will load without being mapped to images.", MessageType.Info);
|
||||
@ -387,8 +386,7 @@ namespace Spine.Unity.Editor {
|
||||
if (hasNulls) {
|
||||
if (targetSkeletonDataAsset.atlasAssets.Length == 1) {
|
||||
EditorGUILayout.HelpBox("Atlas array cannot have null entries!", MessageType.None);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
EditorGUILayout.HelpBox("Atlas array should not have null entries!", MessageType.Error);
|
||||
if (SpineInspectorUtility.CenteredButton(SpineInspectorUtility.TempContent("Remove null entries"))) {
|
||||
var trimmedAtlasAssets = new List<AtlasAssetBase>();
|
||||
@ -539,8 +537,7 @@ namespace Spine.Unity.Editor {
|
||||
if (skin != defaultSkin) {
|
||||
defaultSkin.GetAttachments(i, slotAttachments);
|
||||
defaultSkin.GetAttachments(i, defaultSkinAttachments);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
defaultSkin.GetAttachments(i, defaultSkinAttachments);
|
||||
}
|
||||
}
|
||||
@ -580,7 +577,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
|
||||
void DrawUnityTools () {
|
||||
#if SPINE_SKELETON_MECANIM
|
||||
#if SPINE_SKELETON_MECANIM
|
||||
using (new SpineInspectorUtility.BoxScope()) {
|
||||
isMecanimExpanded = EditorGUILayout.Foldout(isMecanimExpanded, SpineInspectorUtility.TempContent("SkeletonMecanim", SpineInspectorUtility.UnityIcon<SceneAsset>()));
|
||||
if (isMecanimExpanded) {
|
||||
@ -609,7 +606,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void DrawWarningList () {
|
||||
@ -632,14 +629,14 @@ namespace Spine.Unity.Editor {
|
||||
else
|
||||
warnings.Add("Skeleton data file is not a valid Spine JSON or binary file.");
|
||||
} else {
|
||||
#if SPINE_TK2D
|
||||
#if SPINE_TK2D
|
||||
bool searchForSpineAtlasAssets = (compatibilityProblemInfo == null);
|
||||
bool isSpriteCollectionNull = spriteCollection.objectReferenceValue == null;
|
||||
if (!isSpriteCollectionNull) searchForSpineAtlasAssets = false;
|
||||
#else
|
||||
#else
|
||||
// Analysis disable once ConvertToConstant.Local
|
||||
bool searchForSpineAtlasAssets = (compatibilityProblemInfo == null);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (searchForSpineAtlasAssets) {
|
||||
bool detectedNullAtlasEntry = false;
|
||||
@ -673,10 +670,10 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
}
|
||||
|
||||
#if SPINE_TK2D
|
||||
#if SPINE_TK2D
|
||||
if (missingPaths.Count > 0)
|
||||
warnings.Add("Missing regions. SkeletonDataAsset requires tk2DSpriteCollectionData or Spine AtlasAssets.");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
if (missingPaths != null) {
|
||||
@ -692,7 +689,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
|
||||
void DoReimport () {
|
||||
AssetUtility.ImportSpineContent(new [] { AssetDatabase.GetAssetPath(skeletonJSON.objectReferenceValue) }, null, true);
|
||||
AssetUtility.ImportSpineContent(new[] { AssetDatabase.GetAssetPath(skeletonJSON.objectReferenceValue) }, null, true);
|
||||
preview.Clear();
|
||||
InitializeEditor();
|
||||
EditorUtility.SetDirty(targetSkeletonDataAsset);
|
||||
@ -702,7 +699,7 @@ namespace Spine.Unity.Editor {
|
||||
EditorPrefs.SetString(LastSkinKey, skinName);
|
||||
}
|
||||
|
||||
bool NoProblems() {
|
||||
bool NoProblems () {
|
||||
return warnings.Count == 0 && compatibilityProblemInfo == null;
|
||||
}
|
||||
|
||||
@ -760,11 +757,11 @@ namespace Spine.Unity.Editor {
|
||||
Camera PreviewUtilityCamera {
|
||||
get {
|
||||
if (previewRenderUtility == null) return null;
|
||||
#if UNITY_2017_1_OR_NEWER
|
||||
#if UNITY_2017_1_OR_NEWER
|
||||
return previewRenderUtility.camera;
|
||||
#else
|
||||
#else
|
||||
return previewRenderUtility.m_Camera;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -787,7 +784,8 @@ namespace Spine.Unity.Editor {
|
||||
set { if (IsValid) skeletonAnimation.timeScale = value; }
|
||||
}
|
||||
|
||||
public bool IsPlayingAnimation { get {
|
||||
public bool IsPlayingAnimation {
|
||||
get {
|
||||
if (!IsValid) return false;
|
||||
var currentTrack = skeletonAnimation.AnimationState.GetCurrent(0);
|
||||
return currentTrack != null && currentTrack.TimeScale > 0;
|
||||
@ -862,7 +860,7 @@ namespace Spine.Unity.Editor {
|
||||
|
||||
if (previewGameObject == null) {
|
||||
try {
|
||||
previewGameObject = EditorInstantiation.InstantiateSkeletonAnimation(skeletonDataAsset, skinName, useObjectFactory:false).gameObject;
|
||||
previewGameObject = EditorInstantiation.InstantiateSkeletonAnimation(skeletonDataAsset, skinName, useObjectFactory: false).gameObject;
|
||||
|
||||
if (previewGameObject != null) {
|
||||
previewGameObject.hideFlags = HideFlags.HideAndDontSave;
|
||||
@ -872,9 +870,9 @@ namespace Spine.Unity.Editor {
|
||||
skeletonAnimation.LateUpdate();
|
||||
previewGameObject.GetComponent<Renderer>().enabled = false;
|
||||
|
||||
#if SPINE_UNITY_2018_PREVIEW_API
|
||||
#if SPINE_UNITY_2018_PREVIEW_API
|
||||
previewRenderUtility.AddSingleGO(previewGameObject);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
if (this.ActiveTrack != null) cameraAdjustEndFrame = EditorApplication.timeSinceStartup + skeletonAnimation.AnimationState.GetCurrent(0).Alpha;
|
||||
@ -1002,14 +1000,14 @@ namespace Spine.Unity.Editor {
|
||||
Event current = Event.current;
|
||||
int controlID = GUIUtility.GetControlID(SliderHash, FocusType.Passive);
|
||||
switch (current.GetTypeForControl(controlID)) {
|
||||
case EventType.ScrollWheel:
|
||||
if (position.Contains(current.mousePosition)) {
|
||||
cameraOrthoGoal += current.delta.y * 0.06f;
|
||||
cameraOrthoGoal = Mathf.Max(0.01f, cameraOrthoGoal);
|
||||
GUIUtility.hotControl = controlID;
|
||||
current.Use();
|
||||
}
|
||||
break;
|
||||
case EventType.ScrollWheel:
|
||||
if (position.Contains(current.mousePosition)) {
|
||||
cameraOrthoGoal += current.delta.y * 0.06f;
|
||||
cameraOrthoGoal = Mathf.Max(0.01f, cameraOrthoGoal);
|
||||
GUIUtility.hotControl = controlID;
|
||||
current.Use();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -30,12 +30,12 @@
|
||||
//#define BAKE_ALL_BUTTON
|
||||
//#define REGION_BAKING_MESH
|
||||
|
||||
using Spine;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Spine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
using Event = UnityEngine.Event;
|
||||
@ -72,12 +72,12 @@ namespace Spine.Unity.Editor {
|
||||
materials = serializedObject.FindProperty("materials");
|
||||
materials.isExpanded = true;
|
||||
atlasAsset = (SpineAtlasAsset)target;
|
||||
#if REGION_BAKING_MESH
|
||||
#if REGION_BAKING_MESH
|
||||
UpdateBakedList();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#if REGION_BAKING_MESH
|
||||
#if REGION_BAKING_MESH
|
||||
private List<bool> baked;
|
||||
private List<GameObject> bakedObjects;
|
||||
|
||||
@ -99,7 +99,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
override public void OnInspectorGUI () {
|
||||
if (serializedObject.isEditingMultipleObjects) {
|
||||
@ -155,7 +155,7 @@ namespace Spine.Unity.Editor {
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
#if REGION_BAKING_MESH
|
||||
#if REGION_BAKING_MESH
|
||||
if (atlasFile.objectReferenceValue != null) {
|
||||
Atlas atlas = asset.GetAtlas();
|
||||
FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.NonPublic);
|
||||
@ -219,7 +219,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
#if BAKE_ALL_BUTTON
|
||||
#if BAKE_ALL_BUTTON
|
||||
// Check state
|
||||
bool allBaked = true;
|
||||
bool allUnbaked = true;
|
||||
@ -258,10 +258,10 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
#else
|
||||
#else
|
||||
if (atlasFile.objectReferenceValue != null) {
|
||||
|
||||
|
||||
@ -306,7 +306,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
EditorGUI.indentLevel = baseIndent;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (serializedObject.ApplyModifiedProperties() || SpineInspectorUtility.UndoRedoPerformed(Event.current))
|
||||
atlasAsset.Clear();
|
||||
@ -320,7 +320,7 @@ namespace Spine.Unity.Editor {
|
||||
var sprites = new List<SpriteMetaData>(spriteSheet);
|
||||
|
||||
var regions = SpineAtlasAssetInspector.GetRegions(atlas);
|
||||
char[] FilenameDelimiter = {'.'};
|
||||
char[] FilenameDelimiter = { '.' };
|
||||
int updatedCount = 0;
|
||||
int addedCount = 0;
|
||||
|
||||
@ -329,13 +329,13 @@ namespace Spine.Unity.Editor {
|
||||
string textureName = texture.name;
|
||||
bool pageMatch = string.Equals(pageName, textureName, StringComparison.Ordinal);
|
||||
|
||||
// if (pageMatch) {
|
||||
// int pw = r.page.width;
|
||||
// int ph = r.page.height;
|
||||
// bool mismatchSize = pw != texture.width || pw > t.maxTextureSize || ph != texture.height || ph > t.maxTextureSize;
|
||||
// if (mismatchSize)
|
||||
// Debug.LogWarningFormat("Size mismatch found.\nExpected atlas size is {0}x{1}. Texture Import Max Size of texture '{2}'({4}x{5}) is currently set to {3}.", pw, ph, texture.name, t.maxTextureSize, texture.width, texture.height);
|
||||
// }
|
||||
// if (pageMatch) {
|
||||
// int pw = r.page.width;
|
||||
// int ph = r.page.height;
|
||||
// bool mismatchSize = pw != texture.width || pw > t.maxTextureSize || ph != texture.height || ph > t.maxTextureSize;
|
||||
// if (mismatchSize)
|
||||
// Debug.LogWarningFormat("Size mismatch found.\nExpected atlas size is {0}x{1}. Texture Import Max Size of texture '{2}'({4}x{5}) is currently set to {3}.", pw, ph, texture.name, t.maxTextureSize, texture.width, texture.height);
|
||||
// }
|
||||
|
||||
int spriteIndex = pageMatch ? sprites.FindIndex(
|
||||
(s) => string.Equals(s.name, r.name, StringComparison.Ordinal)
|
||||
|
||||
@ -27,12 +27,12 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using Spine;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Spine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
using Event = UnityEngine.Event;
|
||||
|
||||
@ -27,9 +27,9 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Spine.Unity;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
|
||||
@ -45,7 +45,7 @@ namespace Spine.Unity.Editor {
|
||||
bool needsReset;
|
||||
|
||||
#region Context Menu Item
|
||||
[MenuItem ("CONTEXT/SkeletonGraphic/Add BoneFollower GameObject")]
|
||||
[MenuItem("CONTEXT/SkeletonGraphic/Add BoneFollower GameObject")]
|
||||
static void AddBoneFollowerGameObject (MenuCommand cmd) {
|
||||
var skeletonGraphic = cmd.context as SkeletonGraphic;
|
||||
var go = EditorInstantiation.NewGameObject("BoneFollower", true, typeof(RectTransform));
|
||||
@ -63,7 +63,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
|
||||
// Validate
|
||||
[MenuItem ("CONTEXT/SkeletonGraphic/Add BoneFollower GameObject", true)]
|
||||
[MenuItem("CONTEXT/SkeletonGraphic/Add BoneFollower GameObject", true)]
|
||||
static bool ValidateAddBoneFollowerGameObject (MenuCommand cmd) {
|
||||
var skeletonGraphic = cmd.context as SkeletonGraphic;
|
||||
return skeletonGraphic.IsValid;
|
||||
|
||||
@ -43,7 +43,7 @@ namespace Spine.Unity.Editor {
|
||||
bool needsReset;
|
||||
|
||||
#region Context Menu Item
|
||||
[MenuItem ("CONTEXT/SkeletonRenderer/Add BoneFollower GameObject")]
|
||||
[MenuItem("CONTEXT/SkeletonRenderer/Add BoneFollower GameObject")]
|
||||
static void AddBoneFollowerGameObject (MenuCommand cmd) {
|
||||
var skeletonRenderer = cmd.context as SkeletonRenderer;
|
||||
var go = EditorInstantiation.NewGameObject("New BoneFollower", true);
|
||||
@ -60,7 +60,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
|
||||
// Validate
|
||||
[MenuItem ("CONTEXT/SkeletonRenderer/Add BoneFollower GameObject", true)]
|
||||
[MenuItem("CONTEXT/SkeletonRenderer/Add BoneFollower GameObject", true)]
|
||||
static bool ValidateAddBoneFollowerGameObject (MenuCommand cmd) {
|
||||
var skeletonRenderer = cmd.context as SkeletonRenderer;
|
||||
return skeletonRenderer.valid;
|
||||
|
||||
@ -31,9 +31,9 @@
|
||||
#define NEW_PREFAB_SYSTEM
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
using Event = UnityEngine.Event;
|
||||
@ -66,11 +66,11 @@ namespace Spine.Unity.Editor {
|
||||
|
||||
public override void OnInspectorGUI () {
|
||||
|
||||
#if !NEW_PREFAB_SYSTEM
|
||||
#if !NEW_PREFAB_SYSTEM
|
||||
bool isInspectingPrefab = (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab);
|
||||
#else
|
||||
#else
|
||||
bool isInspectingPrefab = false;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Note: when calling InitializeEditor() in OnEnable, it throws exception
|
||||
// "SerializedObjectNotCreatableException: Object at index 0 is null".
|
||||
@ -109,10 +109,10 @@ namespace Spine.Unity.Editor {
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
InitializeEditor();
|
||||
#if !NEW_PREFAB_SYSTEM
|
||||
#if !NEW_PREFAB_SYSTEM
|
||||
if (!isInspectingPrefab)
|
||||
rebuildRequired = true;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
using (new SpineInspectorUtility.LabelWidthScope(150f)) {
|
||||
|
||||
@ -31,9 +31,9 @@
|
||||
#define NEW_PREFAB_SYSTEM
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
using Event = UnityEngine.Event;
|
||||
@ -66,11 +66,11 @@ namespace Spine.Unity.Editor {
|
||||
|
||||
public override void OnInspectorGUI () {
|
||||
|
||||
#if !NEW_PREFAB_SYSTEM
|
||||
#if !NEW_PREFAB_SYSTEM
|
||||
bool isInspectingPrefab = (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab);
|
||||
#else
|
||||
#else
|
||||
bool isInspectingPrefab = false;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Note: when calling InitializeEditor() in OnEnable, it throws exception
|
||||
// "SerializedObjectNotCreatableException: Object at index 0 is null".
|
||||
@ -109,10 +109,10 @@ namespace Spine.Unity.Editor {
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
InitializeEditor();
|
||||
#if !NEW_PREFAB_SYSTEM
|
||||
#if !NEW_PREFAB_SYSTEM
|
||||
if (!isInspectingPrefab)
|
||||
rebuildRequired = true;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
using (new SpineInspectorUtility.LabelWidthScope(150f)) {
|
||||
|
||||
@ -27,9 +27,9 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using Spine;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Spine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
|
||||
|
||||
@ -27,13 +27,13 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using Spine.Unity.Examples;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Spine.Unity.Examples;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
|
||||
|
||||
@ -31,8 +31,8 @@
|
||||
#define NEW_PREFAB_SYSTEM
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
using Icons = SpineEditorUtilities.Icons;
|
||||
@ -71,8 +71,7 @@ namespace Spine.Unity.Editor {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
var component = (SkeletonGraphic)target;
|
||||
return component.IsValid;
|
||||
}
|
||||
@ -136,8 +135,7 @@ namespace Spine.Unity.Editor {
|
||||
foreach (var c in targets) {
|
||||
SpineEditorUtilities.ReloadSkeletonDataAssetAndComponent(c as SkeletonGraphic);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
foreach (var c in targets) {
|
||||
var component = c as SkeletonGraphic;
|
||||
if (!component.IsValid) {
|
||||
@ -243,8 +241,7 @@ namespace Spine.Unity.Editor {
|
||||
meshGeneratorSettings.isExpanded = true;
|
||||
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("'Multiple Canvas Renderers' must be enabled\nwhen 'Enable Separation' is enabled.", Icons.warning), GUILayout.Height(42), GUILayout.Width(340));
|
||||
}
|
||||
}
|
||||
else if (meshRendersIncorrectlyWithSingleRenderer) {
|
||||
} else if (meshRendersIncorrectlyWithSingleRenderer) {
|
||||
using (new SpineInspectorUtility.BoxScope()) {
|
||||
meshGeneratorSettings.isExpanded = true;
|
||||
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("This mesh uses multiple atlas pages. You\n" +
|
||||
@ -298,12 +295,12 @@ namespace Spine.Unity.Editor {
|
||||
if (TargetIsValid && !isInspectingPrefab) {
|
||||
EditorGUILayout.Space();
|
||||
if (SpineInspectorUtility.CenteredButton(new GUIContent("Add Skeleton Utility", Icons.skeletonUtility), 21, true, 200f))
|
||||
foreach (var t in targets) {
|
||||
var component = t as Component;
|
||||
if (component.GetComponent<SkeletonUtility>() == null) {
|
||||
component.gameObject.AddComponent<SkeletonUtility>();
|
||||
foreach (var t in targets) {
|
||||
var component = t as Component;
|
||||
if (component.GetComponent<SkeletonUtility>() == null) {
|
||||
component.gameObject.AddComponent<SkeletonUtility>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasChanged |= EditorGUI.EndChangeCheck();
|
||||
@ -384,12 +381,11 @@ namespace Spine.Unity.Editor {
|
||||
separatorSlotNames.arraySize++;
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
else
|
||||
} else
|
||||
EditorGUILayout.PropertyField(separatorSlotNames, new GUIContent(separatorSlotNames.displayName + string.Format("{0} [{1}]", terminalSlotWarning, separatorSlotNames.arraySize), SeparatorsDescription), true);
|
||||
|
||||
EditorGUILayout.PropertyField(enableSeparatorSlots, SpineInspectorUtility.TempContent("Enable Separation", tooltip: "Whether to enable separation at the above separator slots."));
|
||||
EditorGUILayout.PropertyField(updateSeparatorPartLocation, SpineInspectorUtility.TempContent("Update Part Location", tooltip:"Update separator part GameObject location to match the position of the SkeletonGraphic. This can be helpful when re-parenting parts to a different GameObject."));
|
||||
EditorGUILayout.PropertyField(updateSeparatorPartLocation, SpineInspectorUtility.TempContent("Update Part Location", tooltip: "Update separator part GameObject location to match the position of the SkeletonGraphic. This can be helpful when re-parenting parts to a different GameObject."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -31,13 +31,13 @@
|
||||
|
||||
// Contributed by: Lost Polygon
|
||||
|
||||
using Spine.Unity.Examples;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Spine.Unity.Examples;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
|
||||
@ -137,9 +137,9 @@ namespace Spine.Unity.Editor {
|
||||
|
||||
if (SpineInspectorUtility.LargeCenteredButton(SpineInspectorUtility.TempContent("Clear and Reapply Changes", tooltip: "Removes all non-serialized overrides in the SkeletonRenderer and reapplies the overrides on this component."))) {
|
||||
if (skeletonRenderer != null) {
|
||||
#if SPINE_OPTIONAL_MATERIALOVERRIDE
|
||||
#if SPINE_OPTIONAL_MATERIALOVERRIDE
|
||||
skeletonRenderer.CustomMaterialOverride.Clear();
|
||||
#endif
|
||||
#endif
|
||||
skeletonRenderer.CustomSlotMaterials.Clear();
|
||||
RemoveCustomMaterials();
|
||||
SetCustomMaterials();
|
||||
|
||||
@ -45,10 +45,10 @@
|
||||
#define HAS_ON_POSTPROCESS_PREFAB
|
||||
#endif
|
||||
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
using Event = UnityEngine.Event;
|
||||
@ -216,7 +216,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
}
|
||||
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
if (setMaskNoneMaterialsQueued) {
|
||||
setMaskNoneMaterialsQueued = false;
|
||||
foreach (var c in targets)
|
||||
@ -243,7 +243,7 @@ namespace Spine.Unity.Editor {
|
||||
foreach (var c in targets)
|
||||
EditorDeleteMaskMaterials(c as SkeletonRenderer, SpriteMaskInteraction.VisibleOutsideMask);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if NO_PREFAB_MESH
|
||||
if (isInspectingPrefab) {
|
||||
@ -342,17 +342,17 @@ namespace Spine.Unity.Editor {
|
||||
if (updateWhenInvisible != null) EditorGUILayout.PropertyField(updateWhenInvisible, UpdateWhenInvisibleLabel);
|
||||
|
||||
if (singleSubmesh != null) EditorGUILayout.PropertyField(singleSubmesh, SingleSubmeshLabel);
|
||||
#if PER_MATERIAL_PROPERTY_BLOCKS
|
||||
#if PER_MATERIAL_PROPERTY_BLOCKS
|
||||
if (fixDrawOrder != null) EditorGUILayout.PropertyField(fixDrawOrder, FixDrawOrderLabel);
|
||||
#endif
|
||||
#endif
|
||||
if (immutableTriangles != null) EditorGUILayout.PropertyField(immutableTriangles, ImmubleTrianglesLabel);
|
||||
EditorGUILayout.PropertyField(clearStateOnDisable, ClearStateOnDisableLabel);
|
||||
EditorGUILayout.Space();
|
||||
|
||||
#if HAS_ON_POSTPROCESS_PREFAB
|
||||
#if HAS_ON_POSTPROCESS_PREFAB
|
||||
if (fixPrefabOverrideViaMeshFilter != null) EditorGUILayout.PropertyField(fixPrefabOverrideViaMeshFilter, FixPrefabOverrideViaMeshFilterLabel);
|
||||
EditorGUILayout.Space();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
SeparatorsField(separatorSlotNames);
|
||||
@ -374,7 +374,7 @@ namespace Spine.Unity.Editor {
|
||||
if (tangents != null) EditorGUILayout.PropertyField(tangents, TangentsLabel);
|
||||
}
|
||||
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
EditorGUILayout.Space();
|
||||
if (maskMaterialsNone.arraySize > 0 || maskMaterialsInside.arraySize > 0 || maskMaterialsOutside.arraySize > 0) {
|
||||
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Mask Interaction Materials", SpineInspectorUtility.UnityIcon<SpriteMask>()), EditorStyles.boldLabel);
|
||||
@ -389,7 +389,7 @@ namespace Spine.Unity.Editor {
|
||||
MaskMaterialsEditingField(ref setOutsideMaskMaterialsQueued, ref deleteOutsideMaskMaterialsQueued, maskMaterialsOutside, MaskMaterialsOutsideLabel,
|
||||
differentMaskModesSelected, allowDelete : true, isActiveMaterial: activeMaskInteractionValue == (int)SpriteMaskInteraction.VisibleOutsideMask);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
@ -421,11 +421,11 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
}
|
||||
|
||||
protected void SkeletonRootMotionParameter() {
|
||||
protected void SkeletonRootMotionParameter () {
|
||||
SkeletonRootMotionParameter(targets);
|
||||
}
|
||||
|
||||
public static void SkeletonRootMotionParameter(Object[] targets) {
|
||||
public static void SkeletonRootMotionParameter (Object[] targets) {
|
||||
int rootMotionComponentCount = 0;
|
||||
foreach (var t in targets) {
|
||||
var component = t as Component;
|
||||
@ -454,7 +454,7 @@ namespace Spine.Unity.Editor {
|
||||
foreach (var t in targets) {
|
||||
var component = t as Component;
|
||||
var rootMotionComponent = component.GetComponent<SkeletonRootMotion>();
|
||||
if (rootMotionComponent != null) {
|
||||
if (rootMotionComponent != null) {
|
||||
DestroyImmediate(rootMotionComponent);
|
||||
}
|
||||
}
|
||||
@ -510,7 +510,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
}
|
||||
|
||||
public void MaskMaterialsEditingField(ref bool wasSetRequested, ref bool wasDeleteRequested,
|
||||
public void MaskMaterialsEditingField (ref bool wasSetRequested, ref bool wasDeleteRequested,
|
||||
SerializedProperty maskMaterials, GUIContent label,
|
||||
bool differentMaskModesSelected, bool allowDelete, bool isActiveMaterial) {
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
@ -531,8 +531,7 @@ namespace Spine.Unity.Editor {
|
||||
{
|
||||
if (GUILayout.Button(ClearMaterialButtonLabel, allowDelete ? EditorStyles.miniButtonMid : EditorStyles.miniButtonRight, GUILayout.Width(46f))) {
|
||||
maskMaterials.ClearArray();
|
||||
}
|
||||
else if (allowDelete && GUILayout.Button(DeleteMaterialButtonLabel, EditorStyles.miniButtonRight, GUILayout.Width(46f))) {
|
||||
} else if (allowDelete && GUILayout.Button(DeleteMaterialButtonLabel, EditorStyles.miniButtonRight, GUILayout.Width(46f))) {
|
||||
wasDeleteRequested = true;
|
||||
}
|
||||
if (!allowDelete)
|
||||
@ -542,7 +541,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
}
|
||||
|
||||
void HandleSkinChange() {
|
||||
void HandleSkinChange () {
|
||||
if (!Application.isPlaying && Event.current.type == EventType.Layout && !initialSkinName.hasMultipleDifferentValues) {
|
||||
bool mismatchDetected = false;
|
||||
string newSkinName = initialSkinName.stringValue;
|
||||
@ -574,9 +573,9 @@ namespace Spine.Unity.Editor {
|
||||
// solution or in a separate commit. The current solution does not repaint the Game view because
|
||||
// it is first applying values and in the next editor pass is calling this skin-changing method.
|
||||
if (skeletonRenderer is SkeletonAnimation)
|
||||
((SkeletonAnimation) skeletonRenderer).Update(0f);
|
||||
((SkeletonAnimation)skeletonRenderer).Update(0f);
|
||||
else if (skeletonRenderer is SkeletonMecanim)
|
||||
((SkeletonMecanim) skeletonRenderer).Update();
|
||||
((SkeletonMecanim)skeletonRenderer).Update();
|
||||
|
||||
skeletonRenderer.LateUpdate();
|
||||
return true;
|
||||
@ -584,8 +583,8 @@ namespace Spine.Unity.Editor {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AreAnyMaskMaterialsMissing() {
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
bool AreAnyMaskMaterialsMissing () {
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
foreach (var o in targets) {
|
||||
var component = (SkeletonRenderer)o;
|
||||
if (!component.valid)
|
||||
@ -593,11 +592,11 @@ namespace Spine.Unity.Editor {
|
||||
if (SpineMaskUtilities.AreMaskMaterialsMissing(component))
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
static void EditorSetMaskMaterials(SkeletonRenderer component, SpriteMaskInteraction maskType)
|
||||
{
|
||||
if (component == null) return;
|
||||
@ -610,6 +609,6 @@ namespace Spine.Unity.Editor {
|
||||
if (!SpineEditorUtilities.SkeletonDataAssetIsValid(component.SkeletonDataAsset)) return;
|
||||
SpineMaskUtilities.EditorDeleteMaskMaterials(component.maskMaterials, maskType);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,10 +33,10 @@
|
||||
#define HINGE_JOINT_NEW_BEHAVIOUR
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using Spine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
using Icons = SpineEditorUtilities.Icons;
|
||||
@ -91,7 +91,7 @@ namespace Spine.Unity.Editor {
|
||||
if (skeleton.Skin == null)
|
||||
skin = skeleton.Data.DefaultSkin;
|
||||
|
||||
for(int i = 0; i < slotCount; i++){
|
||||
for (int i = 0; i < slotCount; i++) {
|
||||
Slot slot = skeletonUtility.Skeleton.Slots.Items[i];
|
||||
if (slot.Bone == utilityBone.bone) {
|
||||
var slotAttachments = new List<Skin.SkinEntry>();
|
||||
@ -198,7 +198,7 @@ namespace Spine.Unity.Editor {
|
||||
using (new EditorGUI.DisabledGroupScope(multiObject || boundingBoxTable.Count == 0)) {
|
||||
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Bounding Boxes", Icons.boundingBox), EditorStyles.boldLabel);
|
||||
|
||||
foreach (var entry in boundingBoxTable){
|
||||
foreach (var entry in boundingBoxTable) {
|
||||
Slot slot = entry.Key;
|
||||
var boundingBoxes = entry.Value;
|
||||
|
||||
@ -367,7 +367,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
|
||||
void ApplyJoint2DAngleLimits (HingeJoint2D joint, float rotationLimit, Transform parentBone, Transform bone) {
|
||||
#if HINGE_JOINT_NEW_BEHAVIOUR
|
||||
#if HINGE_JOINT_NEW_BEHAVIOUR
|
||||
float referenceAngle = (parentBone.eulerAngles.z - bone.eulerAngles.z + 360f) % 360f;
|
||||
float minAngle = referenceAngle - rotationLimit;
|
||||
float maxAngle = referenceAngle + rotationLimit;
|
||||
@ -380,7 +380,7 @@ namespace Spine.Unity.Editor {
|
||||
maxAngle += 360f;
|
||||
}
|
||||
#else
|
||||
float minAngle = - rotationLimit;
|
||||
float minAngle = -rotationLimit;
|
||||
float maxAngle = rotationLimit;
|
||||
#endif
|
||||
joint.limits = new JointAngleLimits2D {
|
||||
@ -432,7 +432,7 @@ namespace Spine.Unity.Editor {
|
||||
mirroredChain.SetActive(false);
|
||||
}
|
||||
|
||||
void FlipBone2DHorizontal(Transform bone, Transform mirrorPosition) {
|
||||
void FlipBone2DHorizontal (Transform bone, Transform mirrorPosition) {
|
||||
Vector3 position = bone.position;
|
||||
position.x = 2 * mirrorPosition.position.x - position.x; // = mirrorPosition + (mirrorPosition - bone.position)
|
||||
bone.position = position;
|
||||
@ -520,14 +520,13 @@ namespace Spine.Unity.Editor {
|
||||
utilBone.gameObject.AddComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
static void AttachRigidbodyAndCollider2D(SkeletonUtilityBone utilBone, bool enableCollider = false) {
|
||||
static void AttachRigidbodyAndCollider2D (SkeletonUtilityBone utilBone, bool enableCollider = false) {
|
||||
if (utilBone.GetComponent<Collider2D>() == null) {
|
||||
if (utilBone.bone.Data.Length == 0) {
|
||||
var sphere = utilBone.gameObject.AddComponent<CircleCollider2D>();
|
||||
sphere.radius = 0.1f;
|
||||
sphere.enabled = enableCollider;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
float length = utilBone.bone.Data.Length;
|
||||
var box = utilBone.gameObject.AddComponent<BoxCollider2D>();
|
||||
box.size = new Vector3(length, length / 3f, 0.2f);
|
||||
|
||||
@ -31,12 +31,12 @@
|
||||
#define NEW_PREFAB_SYSTEM
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
using Spine;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEditor.AnimatedValues;
|
||||
using System.Collections.Generic;
|
||||
using Spine;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
using Icons = SpineEditorUtilities.Icons;
|
||||
@ -51,7 +51,7 @@ namespace Spine.Unity.Editor {
|
||||
|
||||
#if !NEW_PREFAB_SYSTEM
|
||||
bool isPrefab;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
readonly GUIContent SpawnHierarchyButtonLabel = new GUIContent("Spawn Hierarchy", Icons.skeleton);
|
||||
|
||||
@ -65,8 +65,7 @@ namespace Spine.Unity.Editor {
|
||||
if (skeletonRenderer != null) {
|
||||
skeletonRenderer.Initialize(false);
|
||||
skeletonRenderer.LateUpdate();
|
||||
}
|
||||
else if (skeletonGraphic != null) {
|
||||
} else if (skeletonGraphic != null) {
|
||||
skeletonGraphic.Initialize(false);
|
||||
skeletonGraphic.LateUpdate();
|
||||
}
|
||||
@ -76,19 +75,19 @@ namespace Spine.Unity.Editor {
|
||||
if ((skeletonRenderer != null && !skeletonRenderer.valid) ||
|
||||
(skeletonGraphic != null && !skeletonGraphic.IsValid)) return;
|
||||
|
||||
#if !NEW_PREFAB_SYSTEM
|
||||
#if !NEW_PREFAB_SYSTEM
|
||||
isPrefab |= PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI () {
|
||||
|
||||
#if !NEW_PREFAB_SYSTEM
|
||||
#if !NEW_PREFAB_SYSTEM
|
||||
if (isPrefab) {
|
||||
GUILayout.Label(new GUIContent("Cannot edit Prefabs", Icons.warning));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
|
||||
@ -27,10 +27,9 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Spine.Unity;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using SpineInspectorUtility = Spine.Unity.Editor.SpineInspectorUtility;
|
||||
|
||||
public class SpineShaderWithOutlineGUI : ShaderGUI {
|
||||
@ -97,7 +96,7 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
|
||||
_StencilComp = FindProperty("_StencilComp", props, false);
|
||||
_StencilRef = FindProperty("_StencilRef", props, false);
|
||||
if (_StencilRef == null)
|
||||
_StencilRef = FindProperty("_Stencil", props, false);
|
||||
_StencilRef = FindProperty("_Stencil", props, false);
|
||||
}
|
||||
|
||||
protected virtual void RenderStencilProperties () {
|
||||
@ -141,8 +140,7 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
|
||||
SwitchShaderToOutlineSettings(material, isOutlineEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
var origFontStyle = EditorStyles.label.fontStyle;
|
||||
EditorStyles.label.fontStyle = FontStyle.Bold;
|
||||
EditorGUILayout.LabelField(_EnableOutlineText);
|
||||
@ -178,8 +176,7 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
|
||||
shaderName = shaderName.Replace(ShaderOutlineNamePrefix, ShaderNormalNamePrefix);
|
||||
_materialEditor.SetShader(Shader.Find(shaderName), false);
|
||||
return;
|
||||
}
|
||||
else if (!isSetToOutlineShader && enableOutline) {
|
||||
} else if (!isSetToOutlineShader && enableOutline) {
|
||||
shaderName = shaderName.Replace(ShaderNormalNamePrefix, ShaderOutlineNamePrefix);
|
||||
_materialEditor.SetShader(Shader.Find(shaderName), false);
|
||||
return;
|
||||
@ -192,8 +189,7 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
|
||||
foreach (Material material in editor.targets) {
|
||||
if (material.shader.name.Contains(ShaderOutlineNamePrefix)) {
|
||||
isAnyEnabled = true;
|
||||
}
|
||||
else if (isAnyEnabled) {
|
||||
} else if (isAnyEnabled) {
|
||||
mixedValue = true;
|
||||
}
|
||||
}
|
||||
@ -206,8 +202,7 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
|
||||
foreach (Material material in editor.targets) {
|
||||
if (material.shader.name.Contains(ShaderWithoutStandardVariantSuffix)) {
|
||||
isAnyShaderWithoutVariant = true;
|
||||
}
|
||||
else if (isAnyShaderWithoutVariant) {
|
||||
} else if (isAnyShaderWithoutVariant) {
|
||||
mixedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,10 +27,9 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Spine.Unity;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using SpineInspectorUtility = Spine.Unity.Editor.SpineInspectorUtility;
|
||||
|
||||
public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
|
||||
@ -528,17 +527,15 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
|
||||
eBlendMode blendMode = GetMaterialBlendMode(material);
|
||||
|
||||
switch (blendMode) {
|
||||
case eBlendMode.Opaque:
|
||||
{
|
||||
SetRenderType(material, "Opaque", useCustomRenderType);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
bool zWrite = HasZWriteEnabled(material);
|
||||
SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderType);
|
||||
}
|
||||
break;
|
||||
case eBlendMode.Opaque: {
|
||||
SetRenderType(material, "Opaque", useCustomRenderType);
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
bool zWrite = HasZWriteEnabled(material);
|
||||
SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderType);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -942,14 +939,13 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
|
||||
case eNormalsMode.FixedNormalsModelSpace:
|
||||
renderType = "SpriteModelSpaceFixedNormal";
|
||||
break;
|
||||
case eNormalsMode.MeshNormals:
|
||||
{
|
||||
//If sprite doesn't write to depth assign custom render type so we can write its depth with soft edges
|
||||
if (!zWrite) {
|
||||
renderType = "Sprite";
|
||||
}
|
||||
case eNormalsMode.MeshNormals: {
|
||||
//If sprite doesn't write to depth assign custom render type so we can write its depth with soft edges
|
||||
if (!zWrite) {
|
||||
renderType = "Sprite";
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1014,8 +1010,7 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
|
||||
foreach (Material material in editor.targets) {
|
||||
if (material.shader.name == shaderType) {
|
||||
isAnyTargetTypeShader = true;
|
||||
}
|
||||
else if (isAnyTargetTypeShader) {
|
||||
} else if (isAnyTargetTypeShader) {
|
||||
mixedValue = true;
|
||||
}
|
||||
}
|
||||
@ -1040,21 +1035,16 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
|
||||
if (material.shader.name == kShaderPixelLit ||
|
||||
material.shader.name == kShaderPixelLitOutline) {
|
||||
return eLightMode.PixelLit;
|
||||
}
|
||||
else if (material.shader.name == kShaderUnlit ||
|
||||
material.shader.name == kShaderUnlitOutline) {
|
||||
} else if (material.shader.name == kShaderUnlit ||
|
||||
material.shader.name == kShaderUnlitOutline) {
|
||||
return eLightMode.Unlit;
|
||||
}
|
||||
else if (material.shader.name == kShaderLitLW) {
|
||||
} else if (material.shader.name == kShaderLitLW) {
|
||||
return eLightMode.LitLightweight;
|
||||
}
|
||||
else if (material.shader.name == kShaderLitURP) {
|
||||
} else if (material.shader.name == kShaderLitURP) {
|
||||
return eLightMode.LitUniversal;
|
||||
}
|
||||
else if (material.shader.name == kShaderLitURP2D) {
|
||||
} else if (material.shader.name == kShaderLitURP2D) {
|
||||
return eLightMode.LitUniversal2D;
|
||||
}
|
||||
else { // if (material.shader.name == kShaderVertexLit || kShaderVertexLitOutline)
|
||||
} else { // if (material.shader.name == kShaderVertexLit || kShaderVertexLitOutline)
|
||||
return eLightMode.VertexLit;
|
||||
}
|
||||
}
|
||||
@ -1091,59 +1081,53 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
|
||||
bool useCustomRenderQueue = material.GetFloat("_CustomRenderQueue") > 0.0f;
|
||||
|
||||
switch (blendMode) {
|
||||
case eBlendMode.Opaque:
|
||||
{
|
||||
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
||||
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
|
||||
SetRenderType(material, "Opaque", useCustomRenderQueue);
|
||||
renderQueue = kSolidQueue;
|
||||
}
|
||||
break;
|
||||
case eBlendMode.Additive:
|
||||
{
|
||||
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
|
||||
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
||||
bool zWrite = HasZWriteEnabled(material);
|
||||
SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue);
|
||||
renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
|
||||
}
|
||||
break;
|
||||
case eBlendMode.SoftAdditive:
|
||||
{
|
||||
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
||||
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcColor);
|
||||
bool zWrite = HasZWriteEnabled(material);
|
||||
SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue);
|
||||
renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
|
||||
}
|
||||
break;
|
||||
case eBlendMode.Multiply:
|
||||
{
|
||||
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
|
||||
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.SrcColor);
|
||||
bool zWrite = HasZWriteEnabled(material);
|
||||
SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue);
|
||||
renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
|
||||
}
|
||||
break;
|
||||
case eBlendMode.Multiplyx2:
|
||||
{
|
||||
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.DstColor);
|
||||
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.SrcColor);
|
||||
bool zWrite = HasZWriteEnabled(material);
|
||||
SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue);
|
||||
renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
||||
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
|
||||
bool zWrite = HasZWriteEnabled(material);
|
||||
SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue);
|
||||
renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
|
||||
}
|
||||
break;
|
||||
case eBlendMode.Opaque: {
|
||||
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
||||
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
|
||||
SetRenderType(material, "Opaque", useCustomRenderQueue);
|
||||
renderQueue = kSolidQueue;
|
||||
}
|
||||
break;
|
||||
case eBlendMode.Additive: {
|
||||
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
|
||||
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
||||
bool zWrite = HasZWriteEnabled(material);
|
||||
SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue);
|
||||
renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
|
||||
}
|
||||
break;
|
||||
case eBlendMode.SoftAdditive: {
|
||||
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
||||
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcColor);
|
||||
bool zWrite = HasZWriteEnabled(material);
|
||||
SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue);
|
||||
renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
|
||||
}
|
||||
break;
|
||||
case eBlendMode.Multiply: {
|
||||
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
|
||||
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.SrcColor);
|
||||
bool zWrite = HasZWriteEnabled(material);
|
||||
SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue);
|
||||
renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
|
||||
}
|
||||
break;
|
||||
case eBlendMode.Multiplyx2: {
|
||||
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.DstColor);
|
||||
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.SrcColor);
|
||||
bool zWrite = HasZWriteEnabled(material);
|
||||
SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue);
|
||||
renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
||||
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
|
||||
bool zWrite = HasZWriteEnabled(material);
|
||||
SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue);
|
||||
renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
material.renderQueue = renderQueue + material.GetInt("_RenderQueue");
|
||||
@ -1209,8 +1193,7 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
|
||||
static bool HasZWriteEnabled (Material material) {
|
||||
if (material.HasProperty("_ZWrite")) {
|
||||
return material.GetFloat("_ZWrite") > 0.0f;
|
||||
}
|
||||
else return true; // Pixel Lit shader always has _ZWrite enabled.
|
||||
} else return true; // Pixel Lit shader always has _ZWrite enabled.
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -29,13 +29,13 @@
|
||||
|
||||
// Contributed by: Mitch Thompson
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Spine;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Spine;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
public struct SpineDrawerValuePair {
|
||||
@ -48,7 +48,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class SpineTreeItemDrawerBase<T> : PropertyDrawer where T:SpineAttributeBase {
|
||||
public abstract class SpineTreeItemDrawerBase<T> : PropertyDrawer where T : SpineAttributeBase {
|
||||
protected SkeletonDataAsset skeletonDataAsset;
|
||||
internal const string NoneStringConstant = "<None>";
|
||||
|
||||
@ -172,7 +172,7 @@ namespace Spine.Unity.Editor {
|
||||
[CustomPropertyDrawer(typeof(SpineSlot))]
|
||||
public class SpineSlotDrawer : SpineTreeItemDrawerBase<SpineSlot> {
|
||||
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.slot; } }
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.slot; } }
|
||||
|
||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineSlot targetAttribute, SkeletonData data) {
|
||||
if (TargetAttribute.includeNone)
|
||||
@ -219,7 +219,7 @@ namespace Spine.Unity.Editor {
|
||||
public class SpineSkinDrawer : SpineTreeItemDrawerBase<SpineSkin> {
|
||||
const string DefaultSkinName = "default";
|
||||
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.skin; } }
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.skin; } }
|
||||
|
||||
internal override string NoneString { get { return TargetAttribute.defaultAsEmptyString ? DefaultSkinName : NoneStringConstant; } }
|
||||
|
||||
@ -267,7 +267,7 @@ namespace Spine.Unity.Editor {
|
||||
[CustomPropertyDrawer(typeof(SpineAnimation))]
|
||||
public class SpineAnimationDrawer : SpineTreeItemDrawerBase<SpineAnimation> {
|
||||
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.animation; } }
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.animation; } }
|
||||
|
||||
public static void GetAnimationMenuItems (SkeletonData data, List<string> outputNames, List<GUIContent> outputMenuItems, bool includeNone = true) {
|
||||
if (data == null) return;
|
||||
@ -309,7 +309,7 @@ namespace Spine.Unity.Editor {
|
||||
[CustomPropertyDrawer(typeof(SpineEvent))]
|
||||
public class SpineEventNameDrawer : SpineTreeItemDrawerBase<SpineEvent> {
|
||||
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.userEvent; } }
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.userEvent; } }
|
||||
|
||||
public static void GetEventMenuItems (SkeletonData data, List<string> eventNames, List<GUIContent> menuItems, bool includeNone = true) {
|
||||
if (data == null) return;
|
||||
@ -354,7 +354,7 @@ namespace Spine.Unity.Editor {
|
||||
[CustomPropertyDrawer(typeof(SpineIkConstraint))]
|
||||
public class SpineIkConstraintDrawer : SpineTreeItemDrawerBase<SpineIkConstraint> {
|
||||
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.constraintIK; } }
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.constraintIK; } }
|
||||
|
||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineIkConstraint targetAttribute, SkeletonData data) {
|
||||
var constraints = skeletonDataAsset.GetSkeletonData(false).IkConstraints;
|
||||
@ -374,7 +374,7 @@ namespace Spine.Unity.Editor {
|
||||
[CustomPropertyDrawer(typeof(SpineTransformConstraint))]
|
||||
public class SpineTransformConstraintDrawer : SpineTreeItemDrawerBase<SpineTransformConstraint> {
|
||||
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.constraintTransform; } }
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.constraintTransform; } }
|
||||
|
||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineTransformConstraint targetAttribute, SkeletonData data) {
|
||||
var constraints = skeletonDataAsset.GetSkeletonData(false).TransformConstraints;
|
||||
@ -393,7 +393,7 @@ namespace Spine.Unity.Editor {
|
||||
[CustomPropertyDrawer(typeof(SpinePathConstraint))]
|
||||
public class SpinePathConstraintDrawer : SpineTreeItemDrawerBase<SpinePathConstraint> {
|
||||
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.constraintPath; } }
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.constraintPath; } }
|
||||
|
||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpinePathConstraint targetAttribute, SkeletonData data) {
|
||||
var constraints = skeletonDataAsset.GetSkeletonData(false).PathConstraints;
|
||||
@ -412,7 +412,7 @@ namespace Spine.Unity.Editor {
|
||||
[CustomPropertyDrawer(typeof(SpineAttachment))]
|
||||
public class SpineAttachmentDrawer : SpineTreeItemDrawerBase<SpineAttachment> {
|
||||
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.genericAttachment; } }
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.genericAttachment; } }
|
||||
|
||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineAttachment targetAttribute, SkeletonData data) {
|
||||
ISkeletonComponent skeletonComponent = GetTargetSkeletonComponent(property);
|
||||
@ -514,7 +514,7 @@ namespace Spine.Unity.Editor {
|
||||
[CustomPropertyDrawer(typeof(SpineBone))]
|
||||
public class SpineBoneDrawer : SpineTreeItemDrawerBase<SpineBone> {
|
||||
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.bone; } }
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.bone; } }
|
||||
|
||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineBone targetAttribute, SkeletonData data) {
|
||||
menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
|
||||
|
||||
@ -51,14 +51,13 @@
|
||||
#define PROBLEMATIC_PACKAGE_ASSET_MODIFICATION
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using CompatibilityProblemInfo = Spine.Unity.SkeletonDataCompatibility.CompatibilityProblemInfo;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
@ -115,7 +114,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
}
|
||||
|
||||
#region Match SkeletonData with Atlases
|
||||
#region Match SkeletonData with Atlases
|
||||
static readonly AttachmentType[] AtlasTypes = { AttachmentType.Region, AttachmentType.Linkedmesh, AttachmentType.Mesh };
|
||||
|
||||
public static List<string> GetRequiredAtlasRegions (string skeletonDataPath) {
|
||||
@ -132,15 +131,13 @@ namespace Spine.Unity.Editor {
|
||||
try {
|
||||
if (spineJson != null) {
|
||||
reader = new StringReader(spineJson.text);
|
||||
}
|
||||
else {
|
||||
} 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.
|
||||
reader = new StreamReader(skeletonDataPath);
|
||||
}
|
||||
root = Json.Deserialize(reader) as Dictionary<string, object>;
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
if (reader != null)
|
||||
reader.Dispose();
|
||||
}
|
||||
@ -195,15 +192,13 @@ namespace Spine.Unity.Editor {
|
||||
try {
|
||||
if (data != null) {
|
||||
input = new MemoryStream(data.bytes);
|
||||
}
|
||||
else {
|
||||
} 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);
|
||||
}
|
||||
binary.ReadSkeletonData(input);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
if (input != null)
|
||||
input.Dispose();
|
||||
}
|
||||
@ -265,7 +260,7 @@ namespace Spine.Unity.Editor {
|
||||
return new ClippingAttachment(name);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
public static void ImportSpineContent (string[] imported, List<string> texturesWithoutMetaFile,
|
||||
bool reimport = false) {
|
||||
@ -278,49 +273,49 @@ namespace Spine.Unity.Editor {
|
||||
foreach (string str in imported) {
|
||||
string extension = Path.GetExtension(str).ToLower();
|
||||
switch (extension) {
|
||||
case ".atlas":
|
||||
if (SpineEditorUtilities.Preferences.atlasTxtImportWarning) {
|
||||
Debug.LogWarningFormat("`{0}` : If this file is a Spine atlas, please change its extension to `.atlas.txt`. This is to allow Unity to recognize it and avoid filename collisions. You can also set this file extension when exporting from the Spine editor.", str);
|
||||
}
|
||||
break;
|
||||
case ".txt":
|
||||
if (str.EndsWith(".atlas.txt", System.StringComparison.Ordinal))
|
||||
atlasPaths.Add(str);
|
||||
break;
|
||||
case ".png":
|
||||
case ".jpg":
|
||||
imagePaths.Add(str);
|
||||
break;
|
||||
case ".json": {
|
||||
var jsonAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(str);
|
||||
case ".atlas":
|
||||
if (SpineEditorUtilities.Preferences.atlasTxtImportWarning) {
|
||||
Debug.LogWarningFormat("`{0}` : If this file is a Spine atlas, please change its extension to `.atlas.txt`. This is to allow Unity to recognize it and avoid filename collisions. You can also set this file extension when exporting from the Spine editor.", str);
|
||||
}
|
||||
break;
|
||||
case ".txt":
|
||||
if (str.EndsWith(".atlas.txt", System.StringComparison.Ordinal))
|
||||
atlasPaths.Add(str);
|
||||
break;
|
||||
case ".png":
|
||||
case ".jpg":
|
||||
imagePaths.Add(str);
|
||||
break;
|
||||
case ".json": {
|
||||
var jsonAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(str);
|
||||
string problemDescription = null;
|
||||
if (jsonAsset != null && IsSpineData(jsonAsset, out compatibilityProblemInfo, ref problemDescription))
|
||||
skeletonPaths.Add(new PathAndProblemInfo(str, compatibilityProblemInfo, problemDescription));
|
||||
if (problemDescription != null)
|
||||
Debug.LogError(problemDescription, jsonAsset);
|
||||
break;
|
||||
}
|
||||
case ".bytes": {
|
||||
if (str.ToLower().EndsWith(".skel.bytes", System.StringComparison.Ordinal)) {
|
||||
var binaryAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(str);
|
||||
string problemDescription = null;
|
||||
if (jsonAsset != null && IsSpineData(jsonAsset, out compatibilityProblemInfo, ref problemDescription))
|
||||
if (IsSpineData(binaryAsset, out compatibilityProblemInfo, ref problemDescription))
|
||||
skeletonPaths.Add(new PathAndProblemInfo(str, compatibilityProblemInfo, problemDescription));
|
||||
if (problemDescription != null)
|
||||
Debug.LogError(problemDescription, jsonAsset);
|
||||
break;
|
||||
}
|
||||
case ".bytes": {
|
||||
if (str.ToLower().EndsWith(".skel.bytes", System.StringComparison.Ordinal)) {
|
||||
var binaryAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(str);
|
||||
string problemDescription = null;
|
||||
if (IsSpineData(binaryAsset, out compatibilityProblemInfo, ref problemDescription))
|
||||
skeletonPaths.Add(new PathAndProblemInfo(str, compatibilityProblemInfo, problemDescription));
|
||||
if (problemDescription != null)
|
||||
Debug.LogError(problemDescription, binaryAsset);
|
||||
}
|
||||
break;
|
||||
Debug.LogError(problemDescription, binaryAsset);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Import atlases first.
|
||||
var newAtlases = new List<AtlasAssetBase>();
|
||||
foreach (string ap in atlasPaths) {
|
||||
#if PROBLEMATIC_PACKAGE_ASSET_MODIFICATION
|
||||
#if PROBLEMATIC_PACKAGE_ASSET_MODIFICATION
|
||||
if (ap.StartsWith("Packages"))
|
||||
continue;
|
||||
#endif
|
||||
#endif
|
||||
TextAsset atlasText = AssetDatabase.LoadAssetAtPath<TextAsset>(ap);
|
||||
AtlasAssetBase atlas = IngestSpineAtlas(atlasText, texturesWithoutMetaFile);
|
||||
newAtlases.Add(atlas);
|
||||
@ -333,10 +328,10 @@ namespace Spine.Unity.Editor {
|
||||
string skeletonPath = skeletonPathEntry.path;
|
||||
var compatibilityProblems = skeletonPathEntry.compatibilityProblems;
|
||||
string otherProblemDescription = skeletonPathEntry.otherProblemDescription;
|
||||
#if PROBLEMATIC_PACKAGE_ASSET_MODIFICATION
|
||||
#if PROBLEMATIC_PACKAGE_ASSET_MODIFICATION
|
||||
if (skeletonPath.StartsWith("Packages"))
|
||||
continue;
|
||||
#endif
|
||||
#endif
|
||||
if (!reimport && CheckForValidSkeletonData(skeletonPath)) {
|
||||
ReloadSkeletonData(skeletonPath, compatibilityProblems);
|
||||
continue;
|
||||
@ -401,16 +396,16 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
}
|
||||
|
||||
static void AddDependentSkeletonIfAtlasChanged(List<PathAndProblemInfo> skeletonPaths, List<string> atlasPaths) {
|
||||
static void AddDependentSkeletonIfAtlasChanged (List<PathAndProblemInfo> skeletonPaths, List<string> atlasPaths) {
|
||||
foreach (var atlasPath in atlasPaths) {
|
||||
string skeletonPathJson = atlasPath.Replace(".atlas.txt", ".json");
|
||||
string skeletonPathBinary = atlasPath.Replace(".atlas.txt", ".skel.bytes");
|
||||
string skeletonPathBinary = atlasPath.Replace(".atlas.txt", ".skel.bytes");
|
||||
string usedSkeletonPath = System.IO.File.Exists(skeletonPathJson) ? skeletonPathJson :
|
||||
System.IO.File.Exists(skeletonPathBinary) ? skeletonPathBinary : null;
|
||||
if (usedSkeletonPath == null)
|
||||
continue;
|
||||
|
||||
if (skeletonPaths.FindIndex(p => { return p.path == usedSkeletonPath; } ) < 0) {
|
||||
if (skeletonPaths.FindIndex(p => { return p.path == usedSkeletonPath; }) < 0) {
|
||||
string problemDescription = null;
|
||||
CompatibilityProblemInfo compatibilityProblemInfo = null;
|
||||
TextAsset textAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(usedSkeletonPath);
|
||||
@ -485,7 +480,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
}
|
||||
|
||||
#region Import Atlases
|
||||
#region Import Atlases
|
||||
static List<AtlasAssetBase> FindAtlasesAtPath (string path) {
|
||||
List<AtlasAssetBase> arr = new List<AtlasAssetBase>();
|
||||
DirectoryInfo dir = new DirectoryInfo(path);
|
||||
@ -528,7 +523,7 @@ namespace Spine.Unity.Editor {
|
||||
atlasAsset.atlasFile = atlasText;
|
||||
|
||||
List<string> pageFiles = new List<string>();
|
||||
Atlas atlas = atlasAsset.GetAtlas(onlyMetaData : true);
|
||||
Atlas atlas = atlasAsset.GetAtlas(onlyMetaData: true);
|
||||
if (atlas != null) {
|
||||
foreach (var page in atlas.Pages)
|
||||
pageFiles.Add(page.name);
|
||||
@ -679,8 +674,7 @@ namespace Spine.Unity.Editor {
|
||||
byte[] bytes = null;
|
||||
try {
|
||||
bytes = tempTexture.EncodeToPNG();
|
||||
}
|
||||
catch (System.Exception) {
|
||||
} catch (System.Exception) {
|
||||
// handled below
|
||||
}
|
||||
if (bytes == null || bytes.Length == 0) {
|
||||
@ -747,8 +741,7 @@ namespace Spine.Unity.Editor {
|
||||
mat = new Material(Shader.Find(SpineEditorUtilities.Preferences.defaultShader));
|
||||
ApplyPMAOrStraightAlphaSettings(mat, SpineEditorUtilities.Preferences.textureSettingsReference);
|
||||
AssetDatabase.CreateAsset(mat, materialPath);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
vestigialMaterials.Remove(mat);
|
||||
}
|
||||
|
||||
@ -857,16 +850,16 @@ namespace Spine.Unity.Editor {
|
||||
|
||||
MaterialChecks.EnablePMATextureAtMaterial(material, isUsingPMAWorkflow);
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Import SkeletonData (json or binary)
|
||||
internal static string GetSkeletonDataAssetFilePath(TextAsset spineJson) {
|
||||
#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)).Replace('\\', '/');
|
||||
return assetPath + "/" + primaryName + SkeletonDataSuffix + ".asset";
|
||||
}
|
||||
|
||||
internal static SkeletonDataAsset IngestIncompatibleSpineProject(TextAsset spineJson,
|
||||
internal static SkeletonDataAsset IngestIncompatibleSpineProject (TextAsset spineJson,
|
||||
CompatibilityProblemInfo compatibilityProblemInfo) {
|
||||
|
||||
if (spineJson == null)
|
||||
@ -941,9 +934,9 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Spine Skeleton Data File Validation
|
||||
#region Spine Skeleton Data File Validation
|
||||
public static bool CheckForValidSkeletonData (string skeletonJSONPath) {
|
||||
string dir = Path.GetDirectoryName(skeletonJSONPath).Replace('\\', '/');
|
||||
TextAsset textAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonJSONPath);
|
||||
@ -966,9 +959,9 @@ namespace Spine.Unity.Editor {
|
||||
compatibilityProblemInfo = SkeletonDataCompatibility.GetCompatibilityProblemInfo(fileVersion);
|
||||
return isSpineSkeletonData;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Dialogs
|
||||
#region Dialogs
|
||||
public static void SkeletonImportDialog (string skeletonPath, List<AtlasAssetBase> localAtlases, List<string> requiredPaths, ref bool abortSkeletonImport) {
|
||||
bool resolved = false;
|
||||
while (!resolved) {
|
||||
@ -981,36 +974,36 @@ namespace Spine.Unity.Editor {
|
||||
);
|
||||
|
||||
switch (result) {
|
||||
case -1:
|
||||
//Debug.Log("Select Atlas");
|
||||
AtlasAssetBase selectedAtlas = BrowseAtlasDialog(Path.GetDirectoryName(skeletonPath).Replace('\\', '/'));
|
||||
if (selectedAtlas != null) {
|
||||
localAtlases.Clear();
|
||||
localAtlases.Add(selectedAtlas);
|
||||
var atlasMatch = AssetUtility.GetMatchingAtlas(requiredPaths, localAtlases);
|
||||
if (atlasMatch != null) {
|
||||
resolved = true;
|
||||
AssetUtility.IngestSpineProject(AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonPath), atlasMatch);
|
||||
}
|
||||
case -1:
|
||||
//Debug.Log("Select Atlas");
|
||||
AtlasAssetBase selectedAtlas = BrowseAtlasDialog(Path.GetDirectoryName(skeletonPath).Replace('\\', '/'));
|
||||
if (selectedAtlas != null) {
|
||||
localAtlases.Clear();
|
||||
localAtlases.Add(selectedAtlas);
|
||||
var atlasMatch = AssetUtility.GetMatchingAtlas(requiredPaths, localAtlases);
|
||||
if (atlasMatch != null) {
|
||||
resolved = true;
|
||||
AssetUtility.IngestSpineProject(AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonPath), atlasMatch);
|
||||
}
|
||||
break;
|
||||
case 0: // Resolve AtlasAssets...
|
||||
var atlasList = MultiAtlasDialog(requiredPaths, Path.GetDirectoryName(skeletonPath).Replace('\\', '/'),
|
||||
Path.GetFileNameWithoutExtension(skeletonPath));
|
||||
if (atlasList != null)
|
||||
AssetUtility.IngestSpineProject(AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonPath), atlasList.ToArray());
|
||||
}
|
||||
break;
|
||||
case 0: // Resolve AtlasAssets...
|
||||
var atlasList = MultiAtlasDialog(requiredPaths, Path.GetDirectoryName(skeletonPath).Replace('\\', '/'),
|
||||
Path.GetFileNameWithoutExtension(skeletonPath));
|
||||
if (atlasList != null)
|
||||
AssetUtility.IngestSpineProject(AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonPath), atlasList.ToArray());
|
||||
|
||||
resolved = true;
|
||||
break;
|
||||
case 1: // Import without atlas
|
||||
Debug.LogWarning("Imported with missing atlases. Skeleton will not render: " + Path.GetFileName(skeletonPath));
|
||||
AssetUtility.IngestSpineProject(AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonPath), new AtlasAssetBase[] { });
|
||||
resolved = true;
|
||||
break;
|
||||
case 2: // Stop importing all
|
||||
abortSkeletonImport = true;
|
||||
resolved = true;
|
||||
break;
|
||||
resolved = true;
|
||||
break;
|
||||
case 1: // Import without atlas
|
||||
Debug.LogWarning("Imported with missing atlases. Skeleton will not render: " + Path.GetFileName(skeletonPath));
|
||||
AssetUtility.IngestSpineProject(AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonPath), new AtlasAssetBase[] { });
|
||||
resolved = true;
|
||||
break;
|
||||
case 2: // Stop importing all
|
||||
abortSkeletonImport = true;
|
||||
resolved = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1069,29 +1062,29 @@ namespace Spine.Unity.Editor {
|
||||
);
|
||||
|
||||
switch (result) {
|
||||
case 0: // Browse...
|
||||
AtlasAssetBase selectedAtlasAsset = BrowseAtlasDialog(lastAtlasPath);
|
||||
if (selectedAtlasAsset != null) {
|
||||
if (!atlasAssets.Contains(selectedAtlasAsset)) {
|
||||
var atlas = selectedAtlasAsset.GetAtlas();
|
||||
bool hasValidRegion = false;
|
||||
foreach (string str in missingRegions) {
|
||||
if (atlas.FindRegion(str) != null) {
|
||||
hasValidRegion = true;
|
||||
break;
|
||||
}
|
||||
case 0: // Browse...
|
||||
AtlasAssetBase selectedAtlasAsset = BrowseAtlasDialog(lastAtlasPath);
|
||||
if (selectedAtlasAsset != null) {
|
||||
if (!atlasAssets.Contains(selectedAtlasAsset)) {
|
||||
var atlas = selectedAtlasAsset.GetAtlas();
|
||||
bool hasValidRegion = false;
|
||||
foreach (string str in missingRegions) {
|
||||
if (atlas.FindRegion(str) != null) {
|
||||
hasValidRegion = true;
|
||||
break;
|
||||
}
|
||||
atlasAssets.Add(selectedAtlasAsset);
|
||||
}
|
||||
atlasAssets.Add(selectedAtlasAsset);
|
||||
}
|
||||
break;
|
||||
case 1: // Import anyway
|
||||
resolved = true;
|
||||
break;
|
||||
case 2: // Cancel
|
||||
atlasAssets = null;
|
||||
resolved = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1: // Import anyway
|
||||
resolved = true;
|
||||
break;
|
||||
case 2: // Cancel
|
||||
atlasAssets = null;
|
||||
resolved = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1114,7 +1107,7 @@ namespace Spine.Unity.Editor {
|
||||
|
||||
return (AtlasAssetBase)obj;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
public static string GetPathSafeName (string name) {
|
||||
foreach (char c in System.IO.Path.GetInvalidFileNameChars()) { // Doesn't handle more obscure file name limitations.
|
||||
@ -1259,7 +1252,7 @@ namespace Spine.Unity.Editor {
|
||||
EditorGUIUtility.PingObject(Selection.activeObject);
|
||||
}
|
||||
|
||||
#region SkeletonMecanim
|
||||
#region SkeletonMecanim
|
||||
#if SPINE_SKELETONMECANIM
|
||||
public static SkeletonMecanim InstantiateSkeletonMecanim (SkeletonDataAsset skeletonDataAsset, string skinName) {
|
||||
return InstantiateSkeletonMecanim(skeletonDataAsset, skeletonDataAsset.GetSkeletonData(true).FindSkin(skinName));
|
||||
@ -1315,6 +1308,6 @@ namespace Spine.Unity.Editor {
|
||||
return newSkeletonMecanim;
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,11 +30,11 @@
|
||||
// from spine-unity 4.0 onward BlendModeMaterialAssets are obsolete and shall be upgraded.
|
||||
#define UPGRADE_ALL_BLEND_MODE_MATERIALS
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
|
||||
@ -82,11 +82,9 @@ namespace Spine.Unity.Editor {
|
||||
TransferSettingsFromModifierAsset(blendModesModifierAsset,
|
||||
skeletonDataAsset, templateMaterials);
|
||||
UpdateBlendmodeMaterialsRequiredState(skeletonDataAsset, skeletonData);
|
||||
}
|
||||
else
|
||||
} else
|
||||
return;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (!UpdateBlendmodeMaterialsRequiredState(skeletonDataAsset, skeletonData))
|
||||
return;
|
||||
AssignPreferencesTemplateMaterials(templateMaterials);
|
||||
@ -112,8 +110,7 @@ namespace Spine.Unity.Editor {
|
||||
if (!skeletonDataAsset.blendModeMaterials.applyAdditiveMaterial) {
|
||||
anyMaterialsChanged |= skeletonDataAsset.blendModeMaterials.additiveMaterials.Count > 0;
|
||||
skeletonDataAsset.blendModeMaterials.additiveMaterials.Clear();
|
||||
}
|
||||
else
|
||||
} else
|
||||
anyMaterialsChanged |= skeletonDataAsset.blendModeMaterials.additiveMaterials.RemoveAll(ifMaterialMissing) != 0;
|
||||
anyMaterialsChanged |= skeletonDataAsset.blendModeMaterials.multiplyMaterials.RemoveAll(ifMaterialMissing) != 0;
|
||||
anyMaterialsChanged |= skeletonDataAsset.blendModeMaterials.screenMaterials.RemoveAll(ifMaterialMissing) != 0;
|
||||
@ -181,21 +178,21 @@ namespace Spine.Unity.Editor {
|
||||
Material materialTemplate = null;
|
||||
string materialSuffix = null;
|
||||
switch (slot.BlendMode) {
|
||||
case BlendMode.Multiply:
|
||||
replacementMaterials = blendModeMaterials.multiplyMaterials;
|
||||
materialTemplate = templateMaterials.multiplyTemplate;
|
||||
materialSuffix = MATERIAL_SUFFIX_MULTIPLY;
|
||||
break;
|
||||
case BlendMode.Screen:
|
||||
replacementMaterials = blendModeMaterials.screenMaterials;
|
||||
materialTemplate = templateMaterials.screenTemplate;
|
||||
materialSuffix = MATERIAL_SUFFIX_SCREEN;
|
||||
break;
|
||||
case BlendMode.Additive:
|
||||
replacementMaterials = blendModeMaterials.additiveMaterials;
|
||||
materialTemplate = templateMaterials.additiveTemplate;
|
||||
materialSuffix = MATERIAL_SUFFIX_ADDITIVE;
|
||||
break;
|
||||
case BlendMode.Multiply:
|
||||
replacementMaterials = blendModeMaterials.multiplyMaterials;
|
||||
materialTemplate = templateMaterials.multiplyTemplate;
|
||||
materialSuffix = MATERIAL_SUFFIX_MULTIPLY;
|
||||
break;
|
||||
case BlendMode.Screen:
|
||||
replacementMaterials = blendModeMaterials.screenMaterials;
|
||||
materialTemplate = templateMaterials.screenTemplate;
|
||||
materialSuffix = MATERIAL_SUFFIX_SCREEN;
|
||||
break;
|
||||
case BlendMode.Additive:
|
||||
replacementMaterials = blendModeMaterials.additiveMaterials;
|
||||
materialTemplate = templateMaterials.additiveTemplate;
|
||||
materialSuffix = MATERIAL_SUFFIX_ADDITIVE;
|
||||
break;
|
||||
}
|
||||
|
||||
skinEntries.Clear();
|
||||
@ -218,9 +215,8 @@ namespace Spine.Unity.Editor {
|
||||
Debug.Log(string.Format("Created blend mode Material '{0}' for SkeletonDataAsset '{1}'.",
|
||||
replacement.material.name, skeletonDataAsset), replacement.material);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Debug.LogError(string.Format("Failed creating blend mode Material for SkeletonDataAsset '{0}',"+
|
||||
} else {
|
||||
Debug.LogError(string.Format("Failed creating blend mode Material for SkeletonDataAsset '{0}'," +
|
||||
" atlas page '{1}', template '{2}'.",
|
||||
skeletonDataAsset.name, originalRegion.page.name, materialTemplate.name),
|
||||
skeletonDataAsset);
|
||||
@ -236,7 +232,7 @@ namespace Spine.Unity.Editor {
|
||||
return !anyCreationFailed;
|
||||
}
|
||||
|
||||
protected static string GetBlendModeMaterialPath(AtlasPage originalPage, string materialSuffix) {
|
||||
protected static string GetBlendModeMaterialPath (AtlasPage originalPage, string materialSuffix) {
|
||||
var originalMaterial = originalPage.rendererObject as Material;
|
||||
var originalPath = AssetDatabase.GetAssetPath(originalMaterial);
|
||||
return originalPath.Replace(".mat", materialSuffix + ".mat");
|
||||
@ -254,8 +250,7 @@ namespace Spine.Unity.Editor {
|
||||
newReplacement.pageName = originalPage.name;
|
||||
if (File.Exists(blendMaterialPath)) {
|
||||
newReplacement.material = AssetDatabase.LoadAssetAtPath<Material>(blendMaterialPath);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
var blendModeMaterial = new Material(materialTemplate) {
|
||||
name = originalMaterial.name + " " + materialTemplate.name,
|
||||
mainTexture = originalMaterial.mainTexture
|
||||
|
||||
@ -43,14 +43,14 @@
|
||||
#define NEWHIERARCHYWINDOWCALLBACKS
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
public partial class SpineEditorUtilities {
|
||||
@ -82,8 +82,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
}
|
||||
|
||||
public static class SpineBuildEnvUtility
|
||||
{
|
||||
public static class SpineBuildEnvUtility {
|
||||
static bool IsInvalidGroup (BuildTargetGroup group) {
|
||||
int gi = (int)group;
|
||||
return
|
||||
@ -115,8 +114,7 @@ namespace Spine.Unity.Editor {
|
||||
|
||||
if (wasDefineAdded) {
|
||||
Debug.LogWarning("Setting Scripting Define Symbol " + define);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Debug.LogWarning("Already Set Scripting Define Symbol " + define);
|
||||
}
|
||||
return wasDefineAdded;
|
||||
@ -143,8 +141,7 @@ namespace Spine.Unity.Editor {
|
||||
|
||||
if (wasDefineRemoved) {
|
||||
Debug.LogWarning("Removing Scripting Define Symbol " + define);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Debug.LogWarning("Already Removed Scripting Define Symbol " + define);
|
||||
}
|
||||
return wasDefineRemoved;
|
||||
|
||||
@ -35,14 +35,14 @@
|
||||
#define NEWPLAYMODECALLBACKS
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
|
||||
@ -51,11 +51,11 @@ namespace Spine.Unity.Editor {
|
||||
|
||||
internal static Dictionary<int, string> savedSkeletonDataAssetAtSKeletonGraphicID = new Dictionary<int, string>();
|
||||
|
||||
#if NEWPLAYMODECALLBACKS
|
||||
#if NEWPLAYMODECALLBACKS
|
||||
internal static void OnPlaymodeStateChanged (PlayModeStateChange stateChange) {
|
||||
#else
|
||||
#else
|
||||
internal static void OnPlaymodeStateChanged () {
|
||||
#endif
|
||||
#endif
|
||||
ReloadAllActiveSkeletonsEditMode();
|
||||
}
|
||||
|
||||
|
||||
@ -31,14 +31,14 @@
|
||||
|
||||
#define SPINE_SKELETONMECANIM
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
public partial class SpineEditorUtilities {
|
||||
|
||||
@ -31,14 +31,14 @@
|
||||
|
||||
#define SPINE_SKELETONMECANIM
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
using EventType = UnityEngine.EventType;
|
||||
@ -155,8 +155,7 @@ namespace Spine.Unity.Editor {
|
||||
if (isUI) {
|
||||
if (usedParent != null && usedParent.GetComponent<RectTransform>() != null) {
|
||||
((SkeletonGraphic)newSkeletonComponent).MatchRectTransformWithBounds();
|
||||
}
|
||||
else
|
||||
} else
|
||||
Debug.Log("Created a UI Skeleton GameObject not under a RectTransform. It may not be visible until you parent it to a canvas.");
|
||||
}
|
||||
|
||||
|
||||
@ -43,19 +43,19 @@
|
||||
#define NEW_PREFERENCES_SETTINGS_PROVIDER
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
public partial class SpineEditorUtilities {
|
||||
|
||||
#if NEW_PREFERENCES_SETTINGS_PROVIDER
|
||||
#if NEW_PREFERENCES_SETTINGS_PROVIDER
|
||||
static class SpineSettingsProviderRegistration
|
||||
{
|
||||
[SettingsProvider]
|
||||
@ -79,27 +79,27 @@ namespace Spine.Unity.Editor {
|
||||
return provider;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#else
|
||||
// Preferences entry point
|
||||
[PreferenceItem("Spine")]
|
||||
static void PreferencesGUI () {
|
||||
Preferences.HandlePreferencesGUI();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if NEW_PREFERENCES_SETTINGS_PROVIDER
|
||||
#if NEW_PREFERENCES_SETTINGS_PROVIDER
|
||||
public static SpinePreferences Preferences {
|
||||
get {
|
||||
return SpinePreferences.GetOrCreateSettings();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if NEW_PREFERENCES_SETTINGS_PROVIDER
|
||||
#if NEW_PREFERENCES_SETTINGS_PROVIDER
|
||||
public static class OldPreferences {
|
||||
#else
|
||||
#else
|
||||
public static class Preferences {
|
||||
#endif
|
||||
#endif
|
||||
const string DEFAULT_SCALE_KEY = "SPINE_DEFAULT_SCALE";
|
||||
public static float defaultScale = SpinePreferences.DEFAULT_DEFAULT_SCALE;
|
||||
|
||||
@ -423,12 +423,12 @@ namespace Spine.Unity.Editor {
|
||||
property.stringValue = material ? AssetDatabase.GetAssetPath(material) : "";
|
||||
}
|
||||
|
||||
#if NEW_PREFERENCES_SETTINGS_PROVIDER
|
||||
#if NEW_PREFERENCES_SETTINGS_PROVIDER
|
||||
public static void PresetAssetPropertyField (SerializedProperty property, GUIContent label) {
|
||||
var texturePreset = (EditorGUILayout.ObjectField(label, AssetDatabase.LoadAssetAtPath<UnityEditor.Presets.Preset>(property.stringValue), typeof(UnityEditor.Presets.Preset), false) as UnityEditor.Presets.Preset);
|
||||
bool isTexturePreset = texturePreset != null && texturePreset.GetTargetTypeName() == "TextureImporter";
|
||||
property.stringValue = isTexturePreset ? AssetDatabase.GetAssetPath(texturePreset) : "";
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,25 +36,23 @@
|
||||
#define HAS_ON_POSTPROCESS_PREFAB
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEngine;
|
||||
#if HAS_BUILD_PROCESS_WITH_REPORT
|
||||
using UnityEditor.Build.Reporting;
|
||||
#endif
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
public class SpineBuildProcessor
|
||||
{
|
||||
public class SpineBuildProcessor {
|
||||
internal static bool isBuilding = false;
|
||||
|
||||
#if HAS_ON_POSTPROCESS_PREFAB
|
||||
static List<string> prefabsToRestore = new List<string>();
|
||||
#endif
|
||||
|
||||
internal static void PreprocessBuild()
|
||||
{
|
||||
internal static void PreprocessBuild () {
|
||||
isBuilding = true;
|
||||
#if HAS_ON_POSTPROCESS_PREFAB
|
||||
var assets = AssetDatabase.FindAssets("t:Prefab");
|
||||
@ -69,8 +67,7 @@ namespace Spine.Unity.Editor {
|
||||
#endif
|
||||
}
|
||||
|
||||
internal static void PostprocessBuild()
|
||||
{
|
||||
internal static void PostprocessBuild () {
|
||||
isBuilding = false;
|
||||
#if HAS_ON_POSTPROCESS_PREFAB
|
||||
foreach (string assetPath in prefabsToRestore) {
|
||||
@ -98,8 +95,7 @@ namespace Spine.Unity.Editor {
|
||||
SpineBuildProcessor.PreprocessBuild();
|
||||
}
|
||||
#else
|
||||
void IPreprocessBuild.OnPreprocessBuild(BuildTarget target, string path)
|
||||
{
|
||||
void IPreprocessBuild.OnPreprocessBuild (BuildTarget target, string path) {
|
||||
SpineBuildProcessor.PreprocessBuild();
|
||||
}
|
||||
#endif
|
||||
@ -123,8 +119,7 @@ namespace Spine.Unity.Editor {
|
||||
SpineBuildProcessor.PostprocessBuild();
|
||||
}
|
||||
#else
|
||||
void IPostprocessBuild.OnPostprocessBuild(BuildTarget target, string path)
|
||||
{
|
||||
void IPostprocessBuild.OnPostprocessBuild (BuildTarget target, string path) {
|
||||
SpineBuildProcessor.PostprocessBuild();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -54,14 +54,14 @@
|
||||
#define HAS_ON_POSTPROCESS_PREFAB
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
using EventType = UnityEngine.EventType;
|
||||
@ -77,11 +77,11 @@ namespace Spine.Unity.Editor {
|
||||
|
||||
// Auto-import entry point for textures
|
||||
void OnPreprocessTexture () {
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
bool customTextureSettingsExist = !assetImporter.importSettingsMissing;
|
||||
#else
|
||||
#else
|
||||
bool customTextureSettingsExist = System.IO.File.Exists(assetImporter.assetPath + ".meta");
|
||||
#endif
|
||||
#endif
|
||||
if (!customTextureSettingsExist) {
|
||||
texturesWithoutMetaFile.Add(assetImporter.assetPath);
|
||||
}
|
||||
@ -159,11 +159,11 @@ namespace Spine.Unity.Editor {
|
||||
static void Initialize () {
|
||||
// Note: Preferences need to be loaded when changing play mode
|
||||
// to initialize handle scale correctly.
|
||||
#if !NEW_PREFERENCES_SETTINGS_PROVIDER
|
||||
#if !NEW_PREFERENCES_SETTINGS_PROVIDER
|
||||
Preferences.Load();
|
||||
#else
|
||||
#else
|
||||
SpinePreferences.Load();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (EditorApplication.isPlayingOrWillChangePlaymode) return;
|
||||
|
||||
@ -175,46 +175,45 @@ namespace Spine.Unity.Editor {
|
||||
if (assets.Length > 0) {
|
||||
assetPath = AssetDatabase.GUIDToAssetPath(assets[0]);
|
||||
editorGUIPath = Path.GetDirectoryName(assetPath).Replace('\\', '/');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
editorGUIPath = editorPath.Replace("/Utility", "/GUI");
|
||||
}
|
||||
Icons.Initialize();
|
||||
|
||||
// Drag and Drop
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
SceneView.duringSceneGui -= DragAndDropInstantiation.SceneViewDragAndDrop;
|
||||
SceneView.duringSceneGui += DragAndDropInstantiation.SceneViewDragAndDrop;
|
||||
#else
|
||||
#else
|
||||
SceneView.onSceneGUIDelegate -= DragAndDropInstantiation.SceneViewDragAndDrop;
|
||||
SceneView.onSceneGUIDelegate += DragAndDropInstantiation.SceneViewDragAndDrop;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
EditorApplication.hierarchyWindowItemOnGUI -= HierarchyHandler.HandleDragAndDrop;
|
||||
EditorApplication.hierarchyWindowItemOnGUI += HierarchyHandler.HandleDragAndDrop;
|
||||
|
||||
// Hierarchy Icons
|
||||
#if NEWPLAYMODECALLBACKS
|
||||
#if NEWPLAYMODECALLBACKS
|
||||
EditorApplication.playModeStateChanged -= HierarchyHandler.IconsOnPlaymodeStateChanged;
|
||||
EditorApplication.playModeStateChanged += HierarchyHandler.IconsOnPlaymodeStateChanged;
|
||||
HierarchyHandler.IconsOnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode);
|
||||
#else
|
||||
#else
|
||||
EditorApplication.playmodeStateChanged -= HierarchyHandler.IconsOnPlaymodeStateChanged;
|
||||
EditorApplication.playmodeStateChanged += HierarchyHandler.IconsOnPlaymodeStateChanged;
|
||||
HierarchyHandler.IconsOnPlaymodeStateChanged();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Data Refresh Edit Mode.
|
||||
// This prevents deserialized SkeletonData from persisting from play mode to edit mode.
|
||||
#if NEWPLAYMODECALLBACKS
|
||||
#if NEWPLAYMODECALLBACKS
|
||||
EditorApplication.playModeStateChanged -= DataReloadHandler.OnPlaymodeStateChanged;
|
||||
EditorApplication.playModeStateChanged += DataReloadHandler.OnPlaymodeStateChanged;
|
||||
DataReloadHandler.OnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode);
|
||||
#else
|
||||
#else
|
||||
EditorApplication.playmodeStateChanged -= DataReloadHandler.OnPlaymodeStateChanged;
|
||||
EditorApplication.playmodeStateChanged += DataReloadHandler.OnPlaymodeStateChanged;
|
||||
DataReloadHandler.OnPlaymodeStateChanged();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (SpineEditorUtilities.Preferences.textureImporterWarning) {
|
||||
IssueWarningsForUnrecommendedTextureSettings();
|
||||
@ -228,7 +227,7 @@ namespace Spine.Unity.Editor {
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public static void IssueWarningsForUnrecommendedTextureSettings() {
|
||||
public static void IssueWarningsForUnrecommendedTextureSettings () {
|
||||
|
||||
string[] atlasDescriptionGUIDs = AssetDatabase.FindAssets("t:textasset .atlas"); // Note: finds ".atlas.txt" but also ".atlas 1.txt" files.
|
||||
for (int i = 0; i < atlasDescriptionGUIDs.Length; ++i) {
|
||||
@ -288,9 +287,9 @@ namespace Spine.Unity.Editor {
|
||||
stateComponent.AnimationState.AssignEventSubscribersFrom(oldAnimationState);
|
||||
}
|
||||
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
SpineMaskUtilities.EditorAssignSpriteMaskMaterials(component);
|
||||
#endif
|
||||
#endif
|
||||
component.LateUpdate();
|
||||
}
|
||||
|
||||
@ -305,8 +304,7 @@ namespace Spine.Unity.Editor {
|
||||
return asset != null && asset.GetSkeletonData(quiet: true) != null;
|
||||
}
|
||||
|
||||
public static bool IssueWarningsForUnrecommendedTextureSettings(string texturePath)
|
||||
{
|
||||
public static bool IssueWarningsForUnrecommendedTextureSettings (string texturePath) {
|
||||
TextureImporter texImporter = (TextureImporter)TextureImporter.GetAtPath(texturePath);
|
||||
if (texImporter == null) {
|
||||
return false;
|
||||
@ -321,7 +319,7 @@ namespace Spine.Unity.Editor {
|
||||
|
||||
string errorMessage = null;
|
||||
if (MaterialChecks.IsTextureSetupProblematic(material, PlayerSettings.colorSpace,
|
||||
texImporter. sRGBTexture, texImporter. mipmapEnabled, texImporter. alphaIsTransparency,
|
||||
texImporter.sRGBTexture, texImporter.mipmapEnabled, texImporter.alphaIsTransparency,
|
||||
texturePath, materialPath, ref errorMessage)) {
|
||||
Debug.LogWarning(errorMessage, material);
|
||||
}
|
||||
@ -492,10 +490,8 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
}
|
||||
|
||||
public class TextureModificationWarningProcessor : UnityEditor.AssetModificationProcessor
|
||||
{
|
||||
static string[] OnWillSaveAssets(string[] paths)
|
||||
{
|
||||
public class TextureModificationWarningProcessor : UnityEditor.AssetModificationProcessor {
|
||||
static string[] OnWillSaveAssets (string[] paths) {
|
||||
if (SpineEditorUtilities.Preferences.textureImporterWarning) {
|
||||
foreach (string path in paths) {
|
||||
if ((path != null) &&
|
||||
|
||||
@ -31,23 +31,23 @@
|
||||
|
||||
#define SPINE_SKELETONMECANIM
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
using EventType = UnityEngine.EventType;
|
||||
|
||||
public static class SpineHandles {
|
||||
public static Color BoneColor { get { return new Color(0.8f, 0.8f, 0.8f, 0.4f); } }
|
||||
public static Color PathColor { get { return new Color(254/255f, 127/255f, 0); } }
|
||||
public static Color TransformContraintColor { get { return new Color(170/255f, 226/255f, 35/255f); } }
|
||||
public static Color IkColor { get { return new Color(228/255f,90/255f,43/255f); } }
|
||||
public static Color PathColor { get { return new Color(254 / 255f, 127 / 255f, 0); } }
|
||||
public static Color TransformContraintColor { get { return new Color(170 / 255f, 226 / 255f, 35 / 255f); } }
|
||||
public static Color IkColor { get { return new Color(228 / 255f, 90 / 255f, 43 / 255f); } }
|
||||
public static Color PointColor { get { return new Color(1f, 1f, 0f, 1f); } }
|
||||
|
||||
static Vector3[] _boneMeshVerts = {
|
||||
@ -63,7 +63,7 @@ namespace Spine.Unity.Editor {
|
||||
_boneMesh = new Mesh {
|
||||
vertices = _boneMeshVerts,
|
||||
uv = new Vector2[4],
|
||||
triangles = new [] { 0, 1, 2, 2, 3, 0 }
|
||||
triangles = new[] { 0, 1, 2, 2, 3, 0 }
|
||||
};
|
||||
_boneMesh.RecalculateBounds();
|
||||
_boneMesh.RecalculateNormals();
|
||||
@ -77,13 +77,13 @@ namespace Spine.Unity.Editor {
|
||||
get {
|
||||
if (_arrowheadMesh == null) {
|
||||
_arrowheadMesh = new Mesh {
|
||||
vertices = new [] {
|
||||
vertices = new[] {
|
||||
new Vector3(0, 0),
|
||||
new Vector3(-0.1f, 0.05f),
|
||||
new Vector3(-0.1f, -0.05f)
|
||||
},
|
||||
uv = new Vector2[3],
|
||||
triangles = new [] { 0, 1, 2 }
|
||||
triangles = new[] { 0, 1, 2 }
|
||||
};
|
||||
_arrowheadMesh.RecalculateBounds();
|
||||
_arrowheadMesh.RecalculateNormals();
|
||||
@ -269,10 +269,10 @@ namespace Spine.Unity.Editor {
|
||||
int n = worldVerticesLength - step;
|
||||
Vector3 p0, p1, p2, p3;
|
||||
for (int i = 2; i < n; i += step) {
|
||||
p0 = m.MultiplyPoint(new Vector3(pv[i], pv[i+1]));
|
||||
p1 = m.MultiplyPoint(new Vector3(pv[i+2], pv[i+3]));
|
||||
p2 = m.MultiplyPoint(new Vector3(pv[i+4], pv[i+5]));
|
||||
p3 = m.MultiplyPoint(new Vector3(pv[i+6], pv[i+7]));
|
||||
p0 = m.MultiplyPoint(new Vector3(pv[i], pv[i + 1]));
|
||||
p1 = m.MultiplyPoint(new Vector3(pv[i + 2], pv[i + 3]));
|
||||
p2 = m.MultiplyPoint(new Vector3(pv[i + 4], pv[i + 5]));
|
||||
p3 = m.MultiplyPoint(new Vector3(pv[i + 6], pv[i + 7]));
|
||||
DrawCubicBezier(p0, p1, p2, p3);
|
||||
}
|
||||
|
||||
@ -290,7 +290,7 @@ namespace Spine.Unity.Editor {
|
||||
SpineHandles.DrawDot(firstPoint, endCapSize);
|
||||
|
||||
//if (!p.Closed) SpineHandles.DrawDot(m.MultiplyPoint(new Vector3(pv[n - 4], pv[n - 3])), endCapSize);
|
||||
if (includeName) Handles.Label(firstPoint + new Vector3(0,0.1f), p.Name, PathNameStyle);
|
||||
if (includeName) Handles.Label(firstPoint + new Vector3(0, 0.1f), p.Name, PathNameStyle);
|
||||
|
||||
Handles.color = ocolor;
|
||||
}
|
||||
@ -385,30 +385,30 @@ namespace Spine.Unity.Editor {
|
||||
pos = bones.Items[0].GetWorldPosition(transform, skeletonRenderScale);
|
||||
switch (bones.Count) {
|
||||
case 1: {
|
||||
Handles.color = handleColor;
|
||||
Handles.DrawLine(targetPos, pos);
|
||||
SpineHandles.DrawBoneCircle(targetPos, handleColor, normal);
|
||||
var m = bones.Items[0].GetMatrix4x4();
|
||||
m.m03 = targetBone.WorldX * skeletonRenderScale;
|
||||
m.m13 = targetBone.WorldY * skeletonRenderScale;
|
||||
SpineHandles.DrawArrowhead(transform.localToWorldMatrix * m);
|
||||
break;
|
||||
}
|
||||
Handles.color = handleColor;
|
||||
Handles.DrawLine(targetPos, pos);
|
||||
SpineHandles.DrawBoneCircle(targetPos, handleColor, normal);
|
||||
var m = bones.Items[0].GetMatrix4x4();
|
||||
m.m03 = targetBone.WorldX * skeletonRenderScale;
|
||||
m.m13 = targetBone.WorldY * skeletonRenderScale;
|
||||
SpineHandles.DrawArrowhead(transform.localToWorldMatrix * m);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
Bone childBone = bones.Items[1];
|
||||
Vector3 child = childBone.GetWorldPosition(transform, skeletonRenderScale);
|
||||
Handles.color = handleColor;
|
||||
Handles.DrawLine(child, pos);
|
||||
Handles.DrawLine(targetPos, child);
|
||||
SpineHandles.DrawBoneCircle(pos, handleColor, normal, 0.5f);
|
||||
SpineHandles.DrawBoneCircle(child, handleColor, normal, 0.5f);
|
||||
SpineHandles.DrawBoneCircle(targetPos, handleColor, normal);
|
||||
var m = childBone.GetMatrix4x4();
|
||||
m.m03 = targetBone.WorldX * skeletonRenderScale;
|
||||
m.m13 = targetBone.WorldY * skeletonRenderScale;
|
||||
SpineHandles.DrawArrowhead(transform.localToWorldMatrix * m);
|
||||
break;
|
||||
}
|
||||
Bone childBone = bones.Items[1];
|
||||
Vector3 child = childBone.GetWorldPosition(transform, skeletonRenderScale);
|
||||
Handles.color = handleColor;
|
||||
Handles.DrawLine(child, pos);
|
||||
Handles.DrawLine(targetPos, child);
|
||||
SpineHandles.DrawBoneCircle(pos, handleColor, normal, 0.5f);
|
||||
SpineHandles.DrawBoneCircle(child, handleColor, normal, 0.5f);
|
||||
SpineHandles.DrawBoneCircle(targetPos, handleColor, normal);
|
||||
var m = childBone.GetMatrix4x4();
|
||||
m.m03 = targetBone.WorldX * skeletonRenderScale;
|
||||
m.m13 = targetBone.WorldY * skeletonRenderScale;
|
||||
SpineHandles.DrawArrowhead(transform.localToWorldMatrix * m);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Handles.Label(targetPos, ikc.Data.Name, SpineHandles.BoneNameStyle);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user