[csharp] Format all source code using formatters/.editorconfig

This commit is contained in:
Mario Zechner 2021-08-18 18:59:53 +02:00
parent 2aced034d3
commit d12b15ca8d
177 changed files with 1782 additions and 1920 deletions

View File

@ -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 &gt; <code>lastTime</code> and &lt;= <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;
}

View File

@ -896,7 +896,7 @@ namespace Spine {
}
timelineMode[i] = AnimationState.HoldFirst;
}
continue_outer: {}
continue_outer: { }
}
}

View File

@ -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();

View File

@ -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);
}

View File

@ -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 () {

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -166,7 +166,7 @@ namespace Spine {
float rotationIK = -bone.ashearX - bone.arotation;
float tx = 0, ty = 0;
switch(bone.data.transformMode) {
switch (bone.data.transformMode) {
case TransformMode.OnlyTranslation:
tx = targetX - bone.worldX;
ty = targetY - bone.worldY;

View File

@ -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,7 +160,7 @@ namespace SharpJson
case 'b':
stringBuffer[idx++] = '\b';
break;
case'f':
case 'f':
stringBuffer[idx++] = '\f';
break;
case '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,8 +244,7 @@ namespace SharpJson
return number;
}
int GetLastIndexOfNumber(int index)
{
int GetLastIndexOfNumber (int index) {
int lastIndex;
for (lastIndex = index; lastIndex < json.Length; lastIndex++) {
@ -267,8 +258,7 @@ namespace SharpJson
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 ':':
@ -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);
}
T EvalLexer<T>(T value)
{
T EvalLexer<T> (T value) {
if (lexer.hasError)
TriggerError("Lexical error ocurred");

View File

@ -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;
}
}

View File

@ -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)

View File

@ -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++)

View File

@ -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;
}
@ -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,7 +1031,7 @@ namespace Spine {
timeline.SetStepped(frame);
break;
case CURVE_BEZIER:
SetBezier (input, timeline, bezier++, frame, 0, time, time2, value, value2, scale);
SetBezier(input, timeline, bezier++, frame, 0, time, time2, value, value2, scale);
break;
}
time = time2;
@ -1043,7 +1043,7 @@ 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;
@ -1070,8 +1070,7 @@ namespace Spine {
input.ReadFloat() * scale, time2, value2);
}
internal class Vertices
{
internal class Vertices {
public int[] bones;
public float[] vertices;
}

View File

@ -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.

View File

@ -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"]) {
@ -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);
@ -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;

View File

@ -28,8 +28,8 @@
*****************************************************************************/
using System;
using System.IO;
using System.Collections.Generic;
using System.IO;
namespace Spine {

View File

@ -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);

View File

@ -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;

View File

@ -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);
}

View File

@ -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));
}
}

View File

@ -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;

View File

@ -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) {

View File

@ -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);

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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]

View File

@ -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 {

View File

@ -34,7 +34,7 @@ namespace Spine.Unity.Examples {
public SkeletonAnimation skeletonAnimation;
[SpineBone(dataField:"skeletonAnimation")]
[SpineBone(dataField: "skeletonAnimation")]
public string boneName;
public Camera cam;

View File

@ -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 {

View File

@ -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";

View File

@ -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)]

View File

@ -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;
}

View File

@ -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.

View File

@ -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 () {

View File

@ -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,7 +113,7 @@ 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;

View File

@ -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 {

View File

@ -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 {

View File

@ -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;

View File

@ -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,7 +58,7 @@ namespace Spine.Unity.Examples {
if (bone != null) bone.SetToSetupPose();
OverrideLocal(spineComponent);
}
#endif
#endif
void Awake () {
spineComponent = GetComponent<ISkeletonAnimation>();

View File

@ -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 {

View File

@ -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;

View File

@ -29,8 +29,8 @@
// Contributed by: Mitch Thompson
using UnityEngine;
using System.Collections;
using UnityEngine;
namespace Spine.Unity.Examples {
public class SkeletonGhostRenderer : MonoBehaviour {

View File

@ -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>

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -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,

View File

@ -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 () {

View File

@ -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;

View File

@ -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();

View File

@ -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 {

View File

@ -29,9 +29,9 @@
// Contributed by: Mitch Thompson
using UnityEngine;
using UnityEditor;
using UnityEngine;
namespace Spine.Unity.Examples {
public class SkeletonRagdoll2DInspector {}
public class SkeletonRagdoll2DInspector { }
}

View File

@ -29,8 +29,8 @@
// Contributed by: Mitch Thompson
using UnityEngine;
using UnityEditor;
using UnityEngine;
namespace Spine.Unity.Examples {

View File

@ -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 { }
}
}

View File

@ -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
}
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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

View File

@ -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,7 +39,7 @@ 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.

View File

@ -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")]

View File

@ -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 {
public class SpineboyFootplanter : MonoBehaviour {
@ -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;

View File

@ -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 {

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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)) {

View File

@ -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)) {

View File

@ -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 {

View File

@ -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 {

View File

@ -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" +
@ -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."));
}
}

View File

@ -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();

View File

@ -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;
@ -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
}
}

View File

@ -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);

View File

@ -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();

View File

@ -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 {
@ -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;
}
}

View File

@ -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,13 +527,11 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
eBlendMode blendMode = GetMaterialBlendMode(material);
switch (blendMode) {
case eBlendMode.Opaque:
{
case eBlendMode.Opaque: {
SetRenderType(material, "Opaque", useCustomRenderType);
}
break;
default:
{
default: {
bool zWrite = HasZWriteEnabled(material);
SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderType);
}
@ -942,8 +939,7 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
case eNormalsMode.FixedNormalsModelSpace:
renderType = "SpriteModelSpaceFixedNormal";
break;
case eNormalsMode.MeshNormals:
{
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";
@ -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 ||
} 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,16 +1081,14 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
bool useCustomRenderQueue = material.GetFloat("_CustomRenderQueue") > 0.0f;
switch (blendMode) {
case eBlendMode.Opaque:
{
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:
{
case eBlendMode.Additive: {
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.One);
bool zWrite = HasZWriteEnabled(material);
@ -1108,8 +1096,7 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
}
break;
case eBlendMode.SoftAdditive:
{
case eBlendMode.SoftAdditive: {
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcColor);
bool zWrite = HasZWriteEnabled(material);
@ -1117,8 +1104,7 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
}
break;
case eBlendMode.Multiply:
{
case eBlendMode.Multiply: {
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.SrcColor);
bool zWrite = HasZWriteEnabled(material);
@ -1126,8 +1112,7 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
}
break;
case eBlendMode.Multiplyx2:
{
case eBlendMode.Multiplyx2: {
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.DstColor);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.SrcColor);
bool zWrite = HasZWriteEnabled(material);
@ -1135,8 +1120,7 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
}
break;
default:
{
default: {
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
bool zWrite = HasZWriteEnabled(material);
@ -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
}

View File

@ -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>";

View File

@ -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) {
@ -317,10 +312,10 @@ namespace Spine.Unity.Editor {
// 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,7 +396,7 @@ 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");
@ -410,7 +405,7 @@ namespace Spine.Unity.Editor {
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) {
@ -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
}
}

View File

@ -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;
@ -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

View File

@ -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;

View File

@ -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();
}

View File

@ -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 {

View File

@ -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.");
}

View File

@ -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
}
}

View File

@ -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

View File

@ -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) &&

View File

@ -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;
}

View File

@ -27,10 +27,10 @@
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace Spine.Unity.Editor {
public static class SpineInspectorUtility {
@ -108,11 +108,11 @@ namespace Spine.Unity.Editor {
return current.type == EventType.ValidateCommand && current.commandName == "UndoRedoPerformed";
}
public static Texture2D UnityIcon<T>() {
public static Texture2D UnityIcon<T> () {
return EditorGUIUtility.ObjectContent(null, typeof(T)).image as Texture2D;
}
public static Texture2D UnityIcon(System.Type type) {
public static Texture2D UnityIcon (System.Type type) {
return EditorGUIUtility.ObjectContent(null, type).image as Texture2D;
}
@ -325,7 +325,7 @@ namespace Spine.Unity.Editor {
static MethodInfo SortingLayerFieldMethod {
get {
if (m_SortingLayerFieldMethod == null)
m_SortingLayerFieldMethod = typeof(EditorGUILayout).GetMethod("SortingLayerField", BindingFlags.Static | BindingFlags.NonPublic, null, new [] { typeof(GUIContent), typeof(SerializedProperty), typeof(GUIStyle) }, null);
m_SortingLayerFieldMethod = typeof(EditorGUILayout).GetMethod("SortingLayerField", BindingFlags.Static | BindingFlags.NonPublic, null, new[] { typeof(GUIContent), typeof(SerializedProperty), typeof(GUIStyle) }, null);
return m_SortingLayerFieldMethod;
}
@ -336,8 +336,8 @@ namespace Spine.Unity.Editor {
public SerializedProperty sortingLayerID;
public SerializedProperty sortingOrder;
public SerializedSortingProperties (Renderer r) : this(new SerializedObject(r)) {}
public SerializedSortingProperties (Object[] renderers) : this(new SerializedObject(renderers)) {}
public SerializedSortingProperties (Renderer r) : this(new SerializedObject(r)) { }
public SerializedSortingProperties (Object[] renderers) : this(new SerializedObject(renderers)) { }
public SerializedSortingProperties (SerializedObject rendererSerializedObject) {
renderer = rendererSerializedObject;
@ -362,7 +362,7 @@ namespace Spine.Unity.Editor {
EditorGUI.BeginChangeCheck();
if (SpineInspectorUtility.SortingLayerFieldMethod != null && prop.sortingLayerID != null)
SpineInspectorUtility.SortingLayerFieldMethod.Invoke(null, new object[] { SortingLayerLabel, prop.sortingLayerID, EditorStyles.popup } );
SpineInspectorUtility.SortingLayerFieldMethod.Invoke(null, new object[] { SortingLayerLabel, prop.sortingLayerID, EditorStyles.popup });
else
EditorGUILayout.PropertyField(prop.sortingLayerID);

Some files were not shown because too many files have changed in this diff Show More