mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Formatting clean up
This commit is contained in:
parent
f73d6e5d1c
commit
18bbcfdc6a
@ -39,68 +39,68 @@ using Spine;
|
|||||||
|
|
||||||
public static class SkeletonExtensions {
|
public static class SkeletonExtensions {
|
||||||
|
|
||||||
public static void SetColor(this Slot slot, Color color) {
|
public static void SetColor (this Slot slot, Color color) {
|
||||||
slot.A = color.a;
|
slot.A = color.a;
|
||||||
slot.R = color.r;
|
slot.R = color.r;
|
||||||
slot.G = color.g;
|
slot.G = color.g;
|
||||||
slot.B = color.b;
|
slot.B = color.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetColor(this Slot slot, Color32 color) {
|
public static void SetColor (this Slot slot, Color32 color) {
|
||||||
slot.A = color.a / 255f;
|
slot.A = color.a / 255f;
|
||||||
slot.R = color.r / 255f;
|
slot.R = color.r / 255f;
|
||||||
slot.G = color.g / 255f;
|
slot.G = color.g / 255f;
|
||||||
slot.B = color.b / 255f;
|
slot.B = color.b / 255f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetColor(this RegionAttachment attachment, Color color) {
|
public static void SetColor (this RegionAttachment attachment, Color color) {
|
||||||
attachment.A = color.a;
|
attachment.A = color.a;
|
||||||
attachment.R = color.r;
|
attachment.R = color.r;
|
||||||
attachment.G = color.g;
|
attachment.G = color.g;
|
||||||
attachment.B = color.b;
|
attachment.B = color.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetColor(this RegionAttachment attachment, Color32 color) {
|
public static void SetColor (this RegionAttachment attachment, Color32 color) {
|
||||||
attachment.A = color.a / 255f;
|
attachment.A = color.a / 255f;
|
||||||
attachment.R = color.r / 255f;
|
attachment.R = color.r / 255f;
|
||||||
attachment.G = color.g / 255f;
|
attachment.G = color.g / 255f;
|
||||||
attachment.B = color.b / 255f;
|
attachment.B = color.b / 255f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetColor(this MeshAttachment attachment, Color color) {
|
public static void SetColor (this MeshAttachment attachment, Color color) {
|
||||||
attachment.A = color.a;
|
attachment.A = color.a;
|
||||||
attachment.R = color.r;
|
attachment.R = color.r;
|
||||||
attachment.G = color.g;
|
attachment.G = color.g;
|
||||||
attachment.B = color.b;
|
attachment.B = color.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetColor(this MeshAttachment attachment, Color32 color) {
|
public static void SetColor (this MeshAttachment attachment, Color32 color) {
|
||||||
attachment.A = color.a / 255f;
|
attachment.A = color.a / 255f;
|
||||||
attachment.R = color.r / 255f;
|
attachment.R = color.r / 255f;
|
||||||
attachment.G = color.g / 255f;
|
attachment.G = color.g / 255f;
|
||||||
attachment.B = color.b / 255f;
|
attachment.B = color.b / 255f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetColor(this SkinnedMeshAttachment attachment, Color color) {
|
public static void SetColor (this SkinnedMeshAttachment attachment, Color color) {
|
||||||
attachment.A = color.a;
|
attachment.A = color.a;
|
||||||
attachment.R = color.r;
|
attachment.R = color.r;
|
||||||
attachment.G = color.g;
|
attachment.G = color.g;
|
||||||
attachment.B = color.b;
|
attachment.B = color.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetColor(this SkinnedMeshAttachment attachment, Color32 color) {
|
public static void SetColor (this SkinnedMeshAttachment attachment, Color32 color) {
|
||||||
attachment.A = color.a / 255f;
|
attachment.A = color.a / 255f;
|
||||||
attachment.R = color.r / 255f;
|
attachment.R = color.r / 255f;
|
||||||
attachment.G = color.g / 255f;
|
attachment.G = color.g / 255f;
|
||||||
attachment.B = color.b / 255f;
|
attachment.B = color.b / 255f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetPosition(this Bone bone, Vector2 position) {
|
public static void SetPosition (this Bone bone, Vector2 position) {
|
||||||
bone.X = position.x;
|
bone.X = position.x;
|
||||||
bone.Y = position.y;
|
bone.Y = position.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetPosition(this Bone bone, Vector3 position) {
|
public static void SetPosition (this Bone bone, Vector3 position) {
|
||||||
bone.X = position.x;
|
bone.X = position.x;
|
||||||
bone.Y = position.y;
|
bone.Y = position.y;
|
||||||
}
|
}
|
||||||
@ -114,13 +114,13 @@ public static class SkeletonExtensions {
|
|||||||
loader = null;
|
loader = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddUnitySprite(this SkeletonData skeletonData, string slotName, Sprite sprite, string skinName = "", string shaderName = "Spine/Skeleton"){
|
public static void AddUnitySprite (this SkeletonData skeletonData, string slotName, Sprite sprite, string skinName = "", string shaderName = "Spine/Skeleton") {
|
||||||
var loader = new SpriteAttachmentLoader(sprite, Shader.Find(shaderName));
|
var loader = new SpriteAttachmentLoader(sprite, Shader.Find(shaderName));
|
||||||
var att = loader.NewRegionAttachment(null, sprite.name, "");
|
var att = loader.NewRegionAttachment(null, sprite.name, "");
|
||||||
|
|
||||||
var slotIndex = skeletonData.FindSlotIndex(slotName);
|
var slotIndex = skeletonData.FindSlotIndex(slotName);
|
||||||
Skin skin = skeletonData.defaultSkin;
|
Skin skin = skeletonData.defaultSkin;
|
||||||
if(skinName != "")
|
if (skinName != "")
|
||||||
skin = skeletonData.FindSkin(skinName);
|
skin = skeletonData.FindSkin(skinName);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -25,11 +25,11 @@ public class SpriteAttacher : MonoBehaviour {
|
|||||||
public void Attach () {
|
public void Attach () {
|
||||||
var skeletonRenderer = GetComponent<SkeletonRenderer>();
|
var skeletonRenderer = GetComponent<SkeletonRenderer>();
|
||||||
|
|
||||||
if(loader == null)
|
if (loader == null)
|
||||||
//create loader instance, tell it what sprite and shader to use
|
//create loader instance, tell it what sprite and shader to use
|
||||||
loader = new SpriteAttachmentLoader(sprite, Shader.Find("Spine/Skeleton"));
|
loader = new SpriteAttachmentLoader(sprite, Shader.Find("Spine/Skeleton"));
|
||||||
|
|
||||||
if(attachment == null)
|
if (attachment == null)
|
||||||
attachment = loader.NewRegionAttachment(null, sprite.name, "");
|
attachment = loader.NewRegionAttachment(null, sprite.name, "");
|
||||||
|
|
||||||
skeletonRenderer.skeleton.FindSlot(slot).Attachment = attachment;
|
skeletonRenderer.skeleton.FindSlot(slot).Attachment = attachment;
|
||||||
@ -102,7 +102,7 @@ public class SpriteAttachmentLoader : AttachmentLoader {
|
|||||||
} else {
|
} else {
|
||||||
//Setup new material
|
//Setup new material
|
||||||
Material mat = new Material(shader);
|
Material mat = new Material(shader);
|
||||||
if(sprite.packed)
|
if (sprite.packed)
|
||||||
mat.name = "Unity Packed Sprite Material";
|
mat.name = "Unity Packed Sprite Material";
|
||||||
else
|
else
|
||||||
mat.name = sprite.name + " Sprite Material";
|
mat.name = sprite.name + " Sprite Material";
|
||||||
@ -131,7 +131,7 @@ public class SpriteAttachmentLoader : AttachmentLoader {
|
|||||||
|
|
||||||
//TODO: make sure this rotation thing actually works
|
//TODO: make sure this rotation thing actually works
|
||||||
bool rotated = false;
|
bool rotated = false;
|
||||||
if(sprite.packed)
|
if (sprite.packed)
|
||||||
rotated = sprite.packingRotation == SpritePackingRotation.Any;
|
rotated = sprite.packingRotation == SpritePackingRotation.Any;
|
||||||
|
|
||||||
//do some math and assign UVs and sizes
|
//do some math and assign UVs and sizes
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user