mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
Formatted source, committed formatter policy.
This commit is contained in:
parent
7b07557e5b
commit
2902fb2ec9
@ -39,21 +39,21 @@ using System.Collections;
|
|||||||
[RequireComponent(typeof(CharacterController))]
|
[RequireComponent(typeof(CharacterController))]
|
||||||
public class BasicPlatformerController : MonoBehaviour {
|
public class BasicPlatformerController : MonoBehaviour {
|
||||||
|
|
||||||
#if !UNITY_4_3 && !UNITY_4_4
|
#if UNITY_4_5
|
||||||
[Header("Controls")]
|
[Header("Controls")]
|
||||||
#endif
|
#endif
|
||||||
public string XAxis = "Horizontal";
|
public string XAxis = "Horizontal";
|
||||||
public string YAxis = "Vertical";
|
public string YAxis = "Vertical";
|
||||||
public string JumpButton = "Jump";
|
public string JumpButton = "Jump";
|
||||||
|
|
||||||
#if !UNITY_4_3 && !UNITY_4_4
|
#if UNITY_4_5
|
||||||
[Header("Moving")]
|
[Header("Moving")]
|
||||||
#endif
|
#endif
|
||||||
public float walkSpeed = 4;
|
public float walkSpeed = 4;
|
||||||
public float runSpeed = 10;
|
public float runSpeed = 10;
|
||||||
public float gravity = 65;
|
public float gravity = 65;
|
||||||
|
|
||||||
#if !UNITY_4_3 && !UNITY_4_4
|
#if UNITY_4_5
|
||||||
[Header("Jumping")]
|
[Header("Jumping")]
|
||||||
#endif
|
#endif
|
||||||
public float jumpSpeed = 25;
|
public float jumpSpeed = 25;
|
||||||
@ -62,13 +62,13 @@ public class BasicPlatformerController : MonoBehaviour {
|
|||||||
public float forceCrouchVelocity = 25;
|
public float forceCrouchVelocity = 25;
|
||||||
public float forceCrouchDuration = 0.5f;
|
public float forceCrouchDuration = 0.5f;
|
||||||
|
|
||||||
#if !UNITY_4_3 && !UNITY_4_4
|
#if UNITY_4_5
|
||||||
[Header("Graphics")]
|
[Header("Graphics")]
|
||||||
#endif
|
#endif
|
||||||
public Transform graphicsRoot;
|
public Transform graphicsRoot;
|
||||||
public SkeletonAnimation skeletonAnimation;
|
public SkeletonAnimation skeletonAnimation;
|
||||||
|
|
||||||
#if !UNITY_4_3 && !UNITY_4_4
|
#if UNITY_4_5
|
||||||
[Header("Animation")]
|
[Header("Animation")]
|
||||||
#endif
|
#endif
|
||||||
public string walkName = "Walk";
|
public string walkName = "Walk";
|
||||||
@ -78,16 +78,13 @@ public class BasicPlatformerController : MonoBehaviour {
|
|||||||
public string fallName = "Fall";
|
public string fallName = "Fall";
|
||||||
public string crouchName = "Crouch";
|
public string crouchName = "Crouch";
|
||||||
|
|
||||||
#if !UNITY_4_3 && !UNITY_4_4
|
#if UNITY_4_5
|
||||||
[Header("Audio")]
|
[Header("Audio")]
|
||||||
#endif
|
#endif
|
||||||
public AudioSource jumpAudioSource;
|
public AudioSource jumpAudioSource;
|
||||||
public AudioSource hardfallAudioSource;
|
public AudioSource hardfallAudioSource;
|
||||||
public AudioSource footstepAudioSource;
|
public AudioSource footstepAudioSource;
|
||||||
public string footstepEventName = "Footstep";
|
public string footstepEventName = "Footstep";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CharacterController controller;
|
CharacterController controller;
|
||||||
Vector2 velocity = Vector2.zero;
|
Vector2 velocity = Vector2.zero;
|
||||||
Vector2 lastVelocity = Vector2.zero;
|
Vector2 lastVelocity = Vector2.zero;
|
||||||
@ -95,12 +92,9 @@ public class BasicPlatformerController : MonoBehaviour {
|
|||||||
float jumpEndTime = 0;
|
float jumpEndTime = 0;
|
||||||
bool jumpInterrupt = false;
|
bool jumpInterrupt = false;
|
||||||
float forceCrouchEndTime;
|
float forceCrouchEndTime;
|
||||||
|
|
||||||
|
|
||||||
Quaternion flippedRotation = Quaternion.Euler(0, 180, 0);
|
Quaternion flippedRotation = Quaternion.Euler(0, 180, 0);
|
||||||
|
|
||||||
void Awake()
|
void Awake () {
|
||||||
{
|
|
||||||
controller = GetComponent<CharacterController>();
|
controller = GetComponent<CharacterController>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,8 +103,7 @@ public class BasicPlatformerController : MonoBehaviour {
|
|||||||
skeletonAnimation.state.Event += HandleEvent;
|
skeletonAnimation.state.Event += HandleEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleEvent (Spine.AnimationState state, int trackIndex, Spine.Event e)
|
void HandleEvent (Spine.AnimationState state, int trackIndex, Spine.Event e) {
|
||||||
{
|
|
||||||
//play some sound if footstep event fired
|
//play some sound if footstep event fired
|
||||||
if (e.Data.Name == footstepEventName) {
|
if (e.Data.Name == footstepEventName) {
|
||||||
footstepAudioSource.Stop();
|
footstepAudioSource.Stop();
|
||||||
@ -118,8 +111,7 @@ public class BasicPlatformerController : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update () {
|
||||||
{
|
|
||||||
//control inputs
|
//control inputs
|
||||||
float x = Input.GetAxis(XAxis);
|
float x = Input.GetAxis(XAxis);
|
||||||
float y = Input.GetAxis(YAxis);
|
float y = Input.GetAxis(YAxis);
|
||||||
@ -129,36 +121,28 @@ public class BasicPlatformerController : MonoBehaviour {
|
|||||||
|
|
||||||
//Calculate control velocity
|
//Calculate control velocity
|
||||||
if (!crouching) {
|
if (!crouching) {
|
||||||
if (Input.GetButtonDown(JumpButton) && controller.isGrounded)
|
if (Input.GetButtonDown(JumpButton) && controller.isGrounded) {
|
||||||
{
|
|
||||||
//jump
|
//jump
|
||||||
jumpAudioSource.Stop();
|
jumpAudioSource.Stop();
|
||||||
jumpAudioSource.Play();
|
jumpAudioSource.Play();
|
||||||
velocity.y = jumpSpeed;
|
velocity.y = jumpSpeed;
|
||||||
jumpEndTime = Time.time + jumpDuration;
|
jumpEndTime = Time.time + jumpDuration;
|
||||||
}
|
} else if (Time.time < jumpEndTime && Input.GetButtonUp(JumpButton)) {
|
||||||
else if (Time.time < jumpEndTime && Input.GetButtonUp(JumpButton))
|
|
||||||
{
|
|
||||||
jumpInterrupt = true;
|
jumpInterrupt = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (x != 0)
|
if (x != 0) {
|
||||||
{
|
|
||||||
//walk or run
|
//walk or run
|
||||||
velocity.x = Mathf.Abs(x) > 0.6f ? runSpeed : walkSpeed;
|
velocity.x = Mathf.Abs(x) > 0.6f ? runSpeed : walkSpeed;
|
||||||
velocity.x *= Mathf.Sign(x);
|
velocity.x *= Mathf.Sign(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jumpInterrupt)
|
if (jumpInterrupt) {
|
||||||
{
|
|
||||||
//interrupt jump and smoothly cut Y velocity
|
//interrupt jump and smoothly cut Y velocity
|
||||||
if (velocity.y > 0)
|
if (velocity.y > 0) {
|
||||||
{
|
|
||||||
velocity.y = Mathf.MoveTowards(velocity.y, 0, Time.deltaTime * 100);
|
velocity.y = Mathf.MoveTowards(velocity.y, 0, Time.deltaTime * 100);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
jumpInterrupt = false;
|
jumpInterrupt = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,8 +154,7 @@ public class BasicPlatformerController : MonoBehaviour {
|
|||||||
//move
|
//move
|
||||||
controller.Move(new Vector3(velocity.x, velocity.y, 0) * Time.deltaTime);
|
controller.Move(new Vector3(velocity.x, velocity.y, 0) * Time.deltaTime);
|
||||||
|
|
||||||
if (controller.isGrounded)
|
if (controller.isGrounded) {
|
||||||
{
|
|
||||||
//cancel out Y velocity if on ground
|
//cancel out Y velocity if on ground
|
||||||
velocity.y = -gravity * Time.deltaTime;
|
velocity.y = -gravity * Time.deltaTime;
|
||||||
jumpInterrupt = false;
|
jumpInterrupt = false;
|
||||||
@ -180,15 +163,12 @@ public class BasicPlatformerController : MonoBehaviour {
|
|||||||
|
|
||||||
Vector2 deltaVelocity = lastVelocity - velocity;
|
Vector2 deltaVelocity = lastVelocity - velocity;
|
||||||
|
|
||||||
if (!lastGrounded && controller.isGrounded)
|
if (!lastGrounded && controller.isGrounded) {
|
||||||
{
|
|
||||||
//detect hard fall
|
//detect hard fall
|
||||||
if ((gravity*Time.deltaTime) - deltaVelocity.y > forceCrouchVelocity)
|
if ((gravity * Time.deltaTime) - deltaVelocity.y > forceCrouchVelocity) {
|
||||||
{
|
|
||||||
forceCrouchEndTime = Time.time + forceCrouchDuration;
|
forceCrouchEndTime = Time.time + forceCrouchDuration;
|
||||||
hardfallAudioSource.Play();
|
hardfallAudioSource.Play();
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
//play footstep audio if light fall because why not
|
//play footstep audio if light fall because why not
|
||||||
footstepAudioSource.Play();
|
footstepAudioSource.Play();
|
||||||
}
|
}
|
||||||
@ -196,28 +176,20 @@ public class BasicPlatformerController : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//graphics updates
|
//graphics updates
|
||||||
if (controller.isGrounded)
|
if (controller.isGrounded) {
|
||||||
{
|
if (crouching) { //crouch
|
||||||
if (crouching) //crouch
|
|
||||||
{
|
|
||||||
skeletonAnimation.AnimationName = crouchName;
|
skeletonAnimation.AnimationName = crouchName;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
if (x == 0) //idle
|
if (x == 0) //idle
|
||||||
skeletonAnimation.AnimationName = idleName;
|
skeletonAnimation.AnimationName = idleName;
|
||||||
else //move
|
else //move
|
||||||
skeletonAnimation.AnimationName = Mathf.Abs(x) > 0.6f ? runName : walkName;
|
skeletonAnimation.AnimationName = Mathf.Abs(x) > 0.6f ? runName : walkName;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (velocity.y > 0) //jump
|
if (velocity.y > 0) //jump
|
||||||
skeletonAnimation.AnimationName = jumpName;
|
skeletonAnimation.AnimationName = jumpName;
|
||||||
else //fall
|
else //fall
|
||||||
skeletonAnimation.AnimationName = fallName;
|
skeletonAnimation.AnimationName = fallName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//flip left or right
|
//flip left or right
|
||||||
|
|||||||
@ -39,10 +39,8 @@ using System.Collections;
|
|||||||
public class ConstrainedCamera : MonoBehaviour {
|
public class ConstrainedCamera : MonoBehaviour {
|
||||||
public Transform target;
|
public Transform target;
|
||||||
public Vector3 offset;
|
public Vector3 offset;
|
||||||
|
|
||||||
public Vector3 min;
|
public Vector3 min;
|
||||||
public Vector3 max;
|
public Vector3 max;
|
||||||
|
|
||||||
public float smoothing = 5f;
|
public float smoothing = 5f;
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
|
|||||||
@ -5,19 +5,15 @@ using System.Collections;
|
|||||||
public class SpineboyController : MonoBehaviour {
|
public class SpineboyController : MonoBehaviour {
|
||||||
|
|
||||||
SkeletonAnimation skeletonAnimation;
|
SkeletonAnimation skeletonAnimation;
|
||||||
|
|
||||||
public string idleAnimation = "idle";
|
public string idleAnimation = "idle";
|
||||||
public string walkAnimation = "walk";
|
public string walkAnimation = "walk";
|
||||||
public string runAnimation = "run";
|
public string runAnimation = "run";
|
||||||
public string hitAnimation = "hit";
|
public string hitAnimation = "hit";
|
||||||
public string deathAnimation = "death";
|
public string deathAnimation = "death";
|
||||||
|
|
||||||
public float walkVelocity = 1;
|
public float walkVelocity = 1;
|
||||||
public float runVelocity = 3;
|
public float runVelocity = 3;
|
||||||
public int hp = 10;
|
public int hp = 10;
|
||||||
|
|
||||||
string currentAnimation = "";
|
string currentAnimation = "";
|
||||||
|
|
||||||
bool hit = false;
|
bool hit = false;
|
||||||
bool dead = false;
|
bool dead = false;
|
||||||
|
|
||||||
@ -25,7 +21,6 @@ public class SpineboyController : MonoBehaviour {
|
|||||||
skeletonAnimation = GetComponent<SkeletonAnimation>();
|
skeletonAnimation = GetComponent<SkeletonAnimation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Update () {
|
void Update () {
|
||||||
if (!dead) {
|
if (!dead) {
|
||||||
float x = Input.GetAxis("Horizontal");
|
float x = Input.GetAxis("Horizontal");
|
||||||
@ -40,24 +35,20 @@ public class SpineboyController : MonoBehaviour {
|
|||||||
if (absX > 0.7f) {
|
if (absX > 0.7f) {
|
||||||
SetAnimation(runAnimation, true);
|
SetAnimation(runAnimation, true);
|
||||||
rigidbody2D.velocity = new Vector2(runVelocity * Mathf.Sign(x), rigidbody2D.velocity.y);
|
rigidbody2D.velocity = new Vector2(runVelocity * Mathf.Sign(x), rigidbody2D.velocity.y);
|
||||||
}
|
} else if (absX > 0) {
|
||||||
else if(absX > 0){
|
|
||||||
SetAnimation(walkAnimation, true);
|
SetAnimation(walkAnimation, true);
|
||||||
rigidbody2D.velocity = new Vector2(walkVelocity * Mathf.Sign(x), rigidbody2D.velocity.y);
|
rigidbody2D.velocity = new Vector2(walkVelocity * Mathf.Sign(x), rigidbody2D.velocity.y);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
SetAnimation(idleAnimation, true);
|
SetAnimation(idleAnimation, true);
|
||||||
rigidbody2D.velocity = new Vector2(0, rigidbody2D.velocity.y);
|
rigidbody2D.velocity = new Vector2(0, rigidbody2D.velocity.y);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
if (skeletonAnimation.state.GetCurrent(0).Animation.Name != hitAnimation)
|
if (skeletonAnimation.state.GetCurrent(0).Animation.Name != hitAnimation)
|
||||||
hit = false;
|
hit = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SetAnimation (string anim, bool loop) {
|
void SetAnimation (string anim, bool loop) {
|
||||||
if (currentAnimation != anim) {
|
if (currentAnimation != anim) {
|
||||||
skeletonAnimation.state.SetAnimation(0, anim, loop);
|
skeletonAnimation.state.SetAnimation(0, anim, loop);
|
||||||
@ -73,8 +64,7 @@ public class SpineboyController : MonoBehaviour {
|
|||||||
if (hp == 0) {
|
if (hp == 0) {
|
||||||
SetAnimation(deathAnimation, false);
|
SetAnimation(deathAnimation, false);
|
||||||
dead = true;
|
dead = true;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
skeletonAnimation.state.SetAnimation(0, hitAnimation, false);
|
skeletonAnimation.state.SetAnimation(0, hitAnimation, false);
|
||||||
skeletonAnimation.state.AddAnimation(0, currentAnimation, true, 0);
|
skeletonAnimation.state.AddAnimation(0, currentAnimation, true, 0);
|
||||||
rigidbody2D.velocity = new Vector2(0, rigidbody2D.velocity.y);
|
rigidbody2D.velocity = new Vector2(0, rigidbody2D.velocity.y);
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 6bc52290ef03f2846ba38d67e2823598
|
guid: 6bc52290ef03f2846ba38d67e2823598
|
||||||
TextureImporter:
|
TextureImporter:
|
||||||
|
fileIDToRecycleName: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
mipmaps:
|
mipmaps:
|
||||||
mipMapMode: 0
|
mipMapMode: 0
|
||||||
@ -21,7 +22,7 @@ TextureImporter:
|
|||||||
generateCubemap: 0
|
generateCubemap: 0
|
||||||
seamlessCubemap: 0
|
seamlessCubemap: 0
|
||||||
textureFormat: -3
|
textureFormat: -3
|
||||||
maxTextureSize: 1024
|
maxTextureSize: 2048
|
||||||
textureSettings:
|
textureSettings:
|
||||||
filterMode: -1
|
filterMode: -1
|
||||||
aniso: -1
|
aniso: -1
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 12c126994123f12468cf4c5a2684078a
|
guid: 12c126994123f12468cf4c5a2684078a
|
||||||
TextureImporter:
|
TextureImporter:
|
||||||
|
fileIDToRecycleName: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
mipmaps:
|
mipmaps:
|
||||||
mipMapMode: 0
|
mipMapMode: 0
|
||||||
@ -21,7 +22,7 @@ TextureImporter:
|
|||||||
generateCubemap: 0
|
generateCubemap: 0
|
||||||
seamlessCubemap: 0
|
seamlessCubemap: 0
|
||||||
textureFormat: -3
|
textureFormat: -3
|
||||||
maxTextureSize: 1024
|
maxTextureSize: 2048
|
||||||
textureSettings:
|
textureSettings:
|
||||||
filterMode: -1
|
filterMode: -1
|
||||||
aniso: -1
|
aniso: -1
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@ -22,7 +22,7 @@ TextureImporter:
|
|||||||
generateCubemap: 0
|
generateCubemap: 0
|
||||||
seamlessCubemap: 0
|
seamlessCubemap: 0
|
||||||
textureFormat: -3
|
textureFormat: -3
|
||||||
maxTextureSize: 1024
|
maxTextureSize: 2048
|
||||||
textureSettings:
|
textureSettings:
|
||||||
filterMode: -1
|
filterMode: -1
|
||||||
aniso: -1
|
aniso: -1
|
||||||
|
|||||||
Binary file not shown.
@ -1,6 +1,7 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 803c2e614a63081439fde6276d110661
|
guid: 803c2e614a63081439fde6276d110661
|
||||||
TextureImporter:
|
TextureImporter:
|
||||||
|
fileIDToRecycleName: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
mipmaps:
|
mipmaps:
|
||||||
mipMapMode: 0
|
mipMapMode: 0
|
||||||
@ -35,6 +36,7 @@ TextureImporter:
|
|||||||
spriteMeshType: 1
|
spriteMeshType: 1
|
||||||
alignment: 0
|
alignment: 0
|
||||||
spritePivot: {x: .5, y: .5}
|
spritePivot: {x: .5, y: .5}
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
spritePixelsToUnits: 100
|
spritePixelsToUnits: 100
|
||||||
alphaIsTransparency: 0
|
alphaIsTransparency: 0
|
||||||
textureType: -1
|
textureType: -1
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@ -1,6 +1,7 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 4261719a8f729a644b2dab6113d1b0ea
|
guid: 4261719a8f729a644b2dab6113d1b0ea
|
||||||
TextureImporter:
|
TextureImporter:
|
||||||
|
fileIDToRecycleName: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
mipmaps:
|
mipmaps:
|
||||||
mipMapMode: 0
|
mipMapMode: 0
|
||||||
@ -21,7 +22,7 @@ TextureImporter:
|
|||||||
generateCubemap: 0
|
generateCubemap: 0
|
||||||
seamlessCubemap: 0
|
seamlessCubemap: 0
|
||||||
textureFormat: -3
|
textureFormat: -3
|
||||||
maxTextureSize: 1024
|
maxTextureSize: 2048
|
||||||
textureSettings:
|
textureSettings:
|
||||||
filterMode: -1
|
filterMode: -1
|
||||||
aniso: -1
|
aniso: -1
|
||||||
@ -35,6 +36,7 @@ TextureImporter:
|
|||||||
spriteMeshType: 1
|
spriteMeshType: 1
|
||||||
alignment: 0
|
alignment: 0
|
||||||
spritePivot: {x: .5, y: .5}
|
spritePivot: {x: .5, y: .5}
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
spritePixelsToUnits: 100
|
spritePixelsToUnits: 100
|
||||||
alphaIsTransparency: 0
|
alphaIsTransparency: 0
|
||||||
textureType: -1
|
textureType: -1
|
||||||
|
|||||||
Binary file not shown.
@ -1,6 +1,7 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 49bb65eefe08e424bbf7a38bc98ec638
|
guid: 49bb65eefe08e424bbf7a38bc98ec638
|
||||||
TextureImporter:
|
TextureImporter:
|
||||||
|
fileIDToRecycleName: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
mipmaps:
|
mipmaps:
|
||||||
mipMapMode: 0
|
mipMapMode: 0
|
||||||
@ -21,7 +22,7 @@ TextureImporter:
|
|||||||
generateCubemap: 0
|
generateCubemap: 0
|
||||||
seamlessCubemap: 0
|
seamlessCubemap: 0
|
||||||
textureFormat: -3
|
textureFormat: -3
|
||||||
maxTextureSize: 1024
|
maxTextureSize: 2048
|
||||||
textureSettings:
|
textureSettings:
|
||||||
filterMode: -1
|
filterMode: -1
|
||||||
aniso: -1
|
aniso: -1
|
||||||
|
|||||||
Binary file not shown.
@ -40,11 +40,10 @@ using Spine;
|
|||||||
public class BoneFollower : MonoBehaviour {
|
public class BoneFollower : MonoBehaviour {
|
||||||
|
|
||||||
[System.NonSerialized]
|
[System.NonSerialized]
|
||||||
public bool valid;
|
public bool
|
||||||
|
valid;
|
||||||
public SkeletonRenderer skeletonRenderer;
|
public SkeletonRenderer skeletonRenderer;
|
||||||
public Bone bone;
|
public Bone bone;
|
||||||
|
|
||||||
public bool followZPosition = true;
|
public bool followZPosition = true;
|
||||||
public bool followBoneRotation = true;
|
public bool followBoneRotation = true;
|
||||||
|
|
||||||
@ -59,9 +58,7 @@ public class BoneFollower : MonoBehaviour {
|
|||||||
|
|
||||||
/// <summary>If a bone isn't set, boneName is used to find the bone.</summary>
|
/// <summary>If a bone isn't set, boneName is used to find the bone.</summary>
|
||||||
public String boneName;
|
public String boneName;
|
||||||
|
|
||||||
public bool resetOnAwake = true;
|
public bool resetOnAwake = true;
|
||||||
|
|
||||||
protected Transform cachedTransform;
|
protected Transform cachedTransform;
|
||||||
protected Transform skeletonTransform;
|
protected Transform skeletonTransform;
|
||||||
|
|
||||||
@ -73,7 +70,8 @@ public class BoneFollower : MonoBehaviour {
|
|||||||
bone = null;
|
bone = null;
|
||||||
cachedTransform = transform;
|
cachedTransform = transform;
|
||||||
valid = skeletonRenderer != null && skeletonRenderer.valid;
|
valid = skeletonRenderer != null && skeletonRenderer.valid;
|
||||||
if (!valid) return;
|
if (!valid)
|
||||||
|
return;
|
||||||
skeletonTransform = skeletonRenderer.transform;
|
skeletonTransform = skeletonRenderer.transform;
|
||||||
|
|
||||||
skeletonRenderer.OnReset -= HandleResetRenderer;
|
skeletonRenderer.OnReset -= HandleResetRenderer;
|
||||||
@ -98,7 +96,6 @@ public class BoneFollower : MonoBehaviour {
|
|||||||
DoUpdate();
|
DoUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void DoUpdate () {
|
public void DoUpdate () {
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
Reset();
|
Reset();
|
||||||
@ -106,13 +103,13 @@ public class BoneFollower : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bone == null) {
|
if (bone == null) {
|
||||||
if (boneName == null || boneName.Length == 0) return;
|
if (boneName == null || boneName.Length == 0)
|
||||||
|
return;
|
||||||
bone = skeletonRenderer.skeleton.FindBone(boneName);
|
bone = skeletonRenderer.skeleton.FindBone(boneName);
|
||||||
if (bone == null) {
|
if (bone == null) {
|
||||||
Debug.LogError("Bone not found: " + boneName, this);
|
Debug.LogError("Bone not found: " + boneName, this);
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,7 +127,8 @@ public class BoneFollower : MonoBehaviour {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
Vector3 targetWorldPosition = skeletonTransform.TransformPoint(new Vector3(bone.worldX, bone.worldY, 0f));
|
Vector3 targetWorldPosition = skeletonTransform.TransformPoint(new Vector3(bone.worldX, bone.worldY, 0f));
|
||||||
if(!followZPosition) targetWorldPosition.z = cachedTransform.position.z;
|
if (!followZPosition)
|
||||||
|
targetWorldPosition.z = cachedTransform.position.z;
|
||||||
|
|
||||||
cachedTransform.position = targetWorldPosition;
|
cachedTransform.position = targetWorldPosition;
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,6 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|||||||
@ -27,7 +27,6 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -36,6 +35,7 @@ using UnityEngine;
|
|||||||
public class BoneFollowerInspector : Editor {
|
public class BoneFollowerInspector : Editor {
|
||||||
private SerializedProperty boneName, skeletonRenderer, followZPosition, followBoneRotation;
|
private SerializedProperty boneName, skeletonRenderer, followZPosition, followBoneRotation;
|
||||||
BoneFollower component;
|
BoneFollower component;
|
||||||
|
|
||||||
void OnEnable () {
|
void OnEnable () {
|
||||||
skeletonRenderer = serializedObject.FindProperty("skeletonRenderer");
|
skeletonRenderer = serializedObject.FindProperty("skeletonRenderer");
|
||||||
boneName = serializedObject.FindProperty("boneName");
|
boneName = serializedObject.FindProperty("boneName");
|
||||||
@ -74,8 +74,7 @@ public class BoneFollowerInspector : Editor {
|
|||||||
String[] bones = new String[1];
|
String[] bones = new String[1];
|
||||||
try {
|
try {
|
||||||
bones = new String[component.skeletonRenderer.skeleton.Data.Bones.Count + 1];
|
bones = new String[component.skeletonRenderer.skeleton.Data.Bones.Count + 1];
|
||||||
}
|
} catch {
|
||||||
catch{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,8 +93,7 @@ public class BoneFollowerInspector : Editor {
|
|||||||
boneName.stringValue = boneIndex == 0 ? null : bones[boneIndex];
|
boneName.stringValue = boneIndex == 0 ? null : bones[boneIndex];
|
||||||
EditorGUILayout.PropertyField(followBoneRotation);
|
EditorGUILayout.PropertyField(followBoneRotation);
|
||||||
EditorGUILayout.PropertyField(followZPosition);
|
EditorGUILayout.PropertyField(followZPosition);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
GUILayout.Label("INVALID");
|
GUILayout.Label("INVALID");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,6 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
@ -50,7 +49,8 @@ public class Menus {
|
|||||||
var selected = Selection.activeObject;
|
var selected = Selection.activeObject;
|
||||||
if (selected != null) {
|
if (selected != null) {
|
||||||
var assetDir = AssetDatabase.GetAssetPath(selected.GetInstanceID());
|
var assetDir = AssetDatabase.GetAssetPath(selected.GetInstanceID());
|
||||||
if (assetDir.Length > 0 && Directory.Exists(assetDir)) dir = assetDir + "/";
|
if (assetDir.Length > 0 && Directory.Exists(assetDir))
|
||||||
|
dir = assetDir + "/";
|
||||||
}
|
}
|
||||||
ScriptableObject asset = ScriptableObject.CreateInstance<T>();
|
ScriptableObject asset = ScriptableObject.CreateInstance<T>();
|
||||||
AssetDatabase.CreateAsset(asset, dir + name + ".asset");
|
AssetDatabase.CreateAsset(asset, dir + name + ".asset");
|
||||||
|
|||||||
@ -27,7 +27,6 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -54,7 +53,8 @@ public class SkeletonAnimationInspector : SkeletonRendererInspector {
|
|||||||
base.gui();
|
base.gui();
|
||||||
|
|
||||||
SkeletonAnimation component = (SkeletonAnimation)target;
|
SkeletonAnimation component = (SkeletonAnimation)target;
|
||||||
if (!component.valid) return;
|
if (!component.valid)
|
||||||
|
return;
|
||||||
|
|
||||||
//catch case where SetAnimation was used to set track 0 without using AnimationName
|
//catch case where SetAnimation was used to set track 0 without using AnimationName
|
||||||
if (Application.isPlaying) {
|
if (Application.isPlaying) {
|
||||||
|
|||||||
@ -32,10 +32,10 @@
|
|||||||
* Automatic import and advanced preview added by Mitch Thompson
|
* Automatic import and advanced preview added by Mitch Thompson
|
||||||
* Full irrevocable rights and permissions granted to Esoteric Software
|
* Full irrevocable rights and permissions granted to Esoteric Software
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
|
||||||
#if !UNITY_4_3
|
#if !UNITY_4_3
|
||||||
using UnityEditor.AnimatedValues;
|
using UnityEditor.AnimatedValues;
|
||||||
#endif
|
#endif
|
||||||
@ -73,8 +73,7 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
|
|
||||||
EditorApplication.update += Update;
|
EditorApplication.update += Update;
|
||||||
|
|
||||||
}
|
} catch {
|
||||||
catch{
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -84,8 +83,7 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
m_initialized = false;
|
m_initialized = false;
|
||||||
EditorApplication.update -= Update;
|
EditorApplication.update -= Update;
|
||||||
this.DestroyPreviewInstances();
|
this.DestroyPreviewInstances();
|
||||||
if (this.m_previewUtility != null)
|
if (this.m_previewUtility != null) {
|
||||||
{
|
|
||||||
this.m_previewUtility.Cleanup();
|
this.m_previewUtility.Cleanup();
|
||||||
this.m_previewUtility = null;
|
this.m_previewUtility = null;
|
||||||
}
|
}
|
||||||
@ -171,14 +169,12 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
StopAnimation();
|
StopAnimation();
|
||||||
}
|
}
|
||||||
GUI.contentColor = Color.white;
|
GUI.contentColor = Color.white;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
if (GUILayout.Button("\u25BA", GUILayout.Width(24))) {
|
if (GUILayout.Button("\u25BA", GUILayout.Width(24))) {
|
||||||
PlayAnimation(a.Name, true);
|
PlayAnimation(a.Name, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
GUILayout.Label("?", GUILayout.Width(24));
|
GUILayout.Label("?", GUILayout.Width(24));
|
||||||
}
|
}
|
||||||
EditorGUILayout.LabelField(new GUIContent(a.Name, SpineEditorUtilities.Icons.animation), new GUIContent(a.Duration.ToString("f3") + "s" + ("(" + (Mathf.RoundToInt(a.Duration * 30)) + ")").PadLeft(12, ' ')));
|
EditorGUILayout.LabelField(new GUIContent(a.Name, SpineEditorUtilities.Icons.animation), new GUIContent(a.Duration.ToString("f3") + "s" + ("(" + (Mathf.RoundToInt(a.Duration * 30)) + ")").PadLeft(12, ' ')));
|
||||||
@ -205,12 +201,10 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
private Vector2 previewDir;
|
private Vector2 previewDir;
|
||||||
private SkeletonAnimation m_skeletonAnimation;
|
private SkeletonAnimation m_skeletonAnimation;
|
||||||
private SkeletonData m_skeletonData;
|
private SkeletonData m_skeletonData;
|
||||||
|
|
||||||
private static int sliderHash = "Slider".GetHashCode();
|
private static int sliderHash = "Slider".GetHashCode();
|
||||||
private float m_lastTime;
|
private float m_lastTime;
|
||||||
private bool m_playing;
|
private bool m_playing;
|
||||||
private bool m_requireRefresh;
|
private bool m_requireRefresh;
|
||||||
|
|
||||||
private Color m_originColor = new Color(0.3f, 0.3f, 0.3f, 1);
|
private Color m_originColor = new Color(0.3f, 0.3f, 0.3f, 1);
|
||||||
|
|
||||||
private void StopAnimation () {
|
private void StopAnimation () {
|
||||||
@ -218,9 +212,9 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
m_playing = false;
|
m_playing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
List<Spine.Event> m_animEvents = new List<Spine.Event>();
|
List<Spine.Event> m_animEvents = new List<Spine.Event>();
|
||||||
List<float> m_animEventFrames = new List<float>();
|
List<float> m_animEventFrames = new List<float>();
|
||||||
|
|
||||||
private void PlayAnimation (string animName, bool loop) {
|
private void PlayAnimation (string animName, bool loop) {
|
||||||
m_animEvents.Clear();
|
m_animEvents.Clear();
|
||||||
m_animEventFrames.Clear();
|
m_animEventFrames.Clear();
|
||||||
@ -243,10 +237,8 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
m_playing = true;
|
m_playing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitPreview()
|
private void InitPreview () {
|
||||||
{
|
if (this.m_previewUtility == null) {
|
||||||
if (this.m_previewUtility == null)
|
|
||||||
{
|
|
||||||
this.m_lastTime = Time.realtimeSinceStartup;
|
this.m_lastTime = Time.realtimeSinceStartup;
|
||||||
this.m_previewUtility = new PreviewRenderUtility(true);
|
this.m_previewUtility = new PreviewRenderUtility(true);
|
||||||
this.m_previewUtility.m_Camera.isOrthoGraphic = true;
|
this.m_previewUtility.m_Camera.isOrthoGraphic = true;
|
||||||
@ -256,11 +248,9 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreatePreviewInstances()
|
private void CreatePreviewInstances () {
|
||||||
{
|
|
||||||
this.DestroyPreviewInstances();
|
this.DestroyPreviewInstances();
|
||||||
if (this.m_previewInstance == null)
|
if (this.m_previewInstance == null) {
|
||||||
{
|
|
||||||
string skinName = EditorPrefs.GetString(m_skeletonDataAssetGUID + "_lastSkin", "");
|
string skinName = EditorPrefs.GetString(m_skeletonDataAssetGUID + "_lastSkin", "");
|
||||||
|
|
||||||
m_previewInstance = SpineEditorUtilities.SpawnAnimatedSkeleton((SkeletonDataAsset)target, skinName).gameObject;
|
m_previewInstance = SpineEditorUtilities.SpawnAnimatedSkeleton((SkeletonDataAsset)target, skinName).gameObject;
|
||||||
@ -281,29 +271,25 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DestroyPreviewInstances()
|
private void DestroyPreviewInstances () {
|
||||||
{
|
if (this.m_previewInstance != null) {
|
||||||
if (this.m_previewInstance != null)
|
|
||||||
{
|
|
||||||
DestroyImmediate(this.m_previewInstance);
|
DestroyImmediate(this.m_previewInstance);
|
||||||
m_previewInstance = null;
|
m_previewInstance = null;
|
||||||
}
|
}
|
||||||
m_initialized = false;
|
m_initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool HasPreviewGUI ()
|
public override bool HasPreviewGUI () {
|
||||||
{
|
|
||||||
//TODO: validate json data
|
//TODO: validate json data
|
||||||
return skeletonJSON.objectReferenceValue != null;
|
return skeletonJSON.objectReferenceValue != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture m_previewTex = new Texture();
|
Texture m_previewTex = new Texture();
|
||||||
public override void OnInteractivePreviewGUI(Rect r, GUIStyle background)
|
|
||||||
{
|
public override void OnInteractivePreviewGUI (Rect r, GUIStyle background) {
|
||||||
this.InitPreview();
|
this.InitPreview();
|
||||||
|
|
||||||
if (UnityEngine.Event.current.type == EventType.Repaint)
|
if (UnityEngine.Event.current.type == EventType.Repaint) {
|
||||||
{
|
|
||||||
if (m_requireRefresh) {
|
if (m_requireRefresh) {
|
||||||
this.m_previewUtility.BeginPreview(r, background);
|
this.m_previewUtility.BeginPreview(r, background);
|
||||||
this.DoRenderPreview(true);
|
this.DoRenderPreview(true);
|
||||||
@ -324,6 +310,7 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
float m_orthoGoal = 1;
|
float m_orthoGoal = 1;
|
||||||
Vector3 m_posGoal = new Vector3(0, 0, -10);
|
Vector3 m_posGoal = new Vector3(0, 0, -10);
|
||||||
double m_adjustFrameEndTime = 0;
|
double m_adjustFrameEndTime = 0;
|
||||||
|
|
||||||
private void AdjustCameraGoals (bool calculateMixTime) {
|
private void AdjustCameraGoals (bool calculateMixTime) {
|
||||||
if (calculateMixTime) {
|
if (calculateMixTime) {
|
||||||
if (m_skeletonAnimation.state.GetCurrent(0) != null) {
|
if (m_skeletonAnimation.state.GetCurrent(0) != null) {
|
||||||
@ -366,8 +353,7 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoRenderPreview(bool drawHandles)
|
private void DoRenderPreview (bool drawHandles) {
|
||||||
{
|
|
||||||
GameObject go = this.m_previewInstance;
|
GameObject go = this.m_previewInstance;
|
||||||
|
|
||||||
if (m_requireRefresh) {
|
if (m_requireRefresh) {
|
||||||
@ -375,8 +361,7 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
|
|
||||||
if (EditorApplication.isPlaying) {
|
if (EditorApplication.isPlaying) {
|
||||||
//do nothing
|
//do nothing
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
m_skeletonAnimation.Update((Time.realtimeSinceStartup - m_lastTime));
|
m_skeletonAnimation.Update((Time.realtimeSinceStartup - m_lastTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,11 +391,9 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
if (m_playing) {
|
if (m_playing) {
|
||||||
m_requireRefresh = true;
|
m_requireRefresh = true;
|
||||||
Repaint();
|
Repaint();
|
||||||
}
|
} else if (m_requireRefresh) {
|
||||||
else if (m_requireRefresh) {
|
|
||||||
Repaint();
|
Repaint();
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
#if !UNITY_4_3
|
#if !UNITY_4_3
|
||||||
if (m_showAnimationList.isAnimating)
|
if (m_showAnimationList.isAnimating)
|
||||||
Repaint();
|
Repaint();
|
||||||
@ -577,17 +560,14 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public override GUIContent GetPreviewTitle ()
|
public override GUIContent GetPreviewTitle () {
|
||||||
{
|
|
||||||
return new GUIContent("Preview");
|
return new GUIContent("Preview");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnPreviewSettings ()
|
public override void OnPreviewSettings () {
|
||||||
{
|
|
||||||
if (!m_initialized) {
|
if (!m_initialized) {
|
||||||
GUILayout.HorizontalSlider(0, 0, 2, GUILayout.MaxWidth(64));
|
GUILayout.HorizontalSlider(0, 0, 2, GUILayout.MaxWidth(64));
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
float speed = GUILayout.HorizontalSlider(m_skeletonAnimation.timeScale, 0, 2, GUILayout.MaxWidth(64));
|
float speed = GUILayout.HorizontalSlider(m_skeletonAnimation.timeScale, 0, 2, GUILayout.MaxWidth(64));
|
||||||
|
|
||||||
//snap to nearest 0.25
|
//snap to nearest 0.25
|
||||||
@ -601,8 +581,7 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
|
|
||||||
//TODO: Fix first-import error
|
//TODO: Fix first-import error
|
||||||
//TODO: Update preview without thumbnail
|
//TODO: Update preview without thumbnail
|
||||||
public override Texture2D RenderStaticPreview (string assetPath, UnityEngine.Object[] subAssets, int width, int height)
|
public override Texture2D RenderStaticPreview (string assetPath, UnityEngine.Object[] subAssets, int width, int height) {
|
||||||
{
|
|
||||||
Texture2D tex = new Texture2D(width, height, TextureFormat.ARGB32, false);
|
Texture2D tex = new Texture2D(width, height, TextureFormat.ARGB32, false);
|
||||||
|
|
||||||
this.InitPreview();
|
this.InitPreview();
|
||||||
|
|||||||
@ -27,7 +27,6 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -64,7 +63,8 @@ public class SkeletonRendererInspector : Editor {
|
|||||||
if (!component.valid) {
|
if (!component.valid) {
|
||||||
component.Reset();
|
component.Reset();
|
||||||
component.LateUpdate();
|
component.LateUpdate();
|
||||||
if (!component.valid) return;
|
if (!component.valid)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initial skin name.
|
// Initial skin name.
|
||||||
@ -100,7 +100,8 @@ public class SkeletonRendererInspector : Editor {
|
|||||||
if (serializedObject.ApplyModifiedProperties() ||
|
if (serializedObject.ApplyModifiedProperties() ||
|
||||||
(Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
|
(Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
|
||||||
) {
|
) {
|
||||||
if (!Application.isPlaying) ((SkeletonRenderer)target).Reset();
|
if (!Application.isPlaying)
|
||||||
|
((SkeletonRenderer)target).Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,6 @@
|
|||||||
* Spine Editor Utilities created by Mitch Thompson
|
* Spine Editor Utilities created by Mitch Thompson
|
||||||
* Full irrevocable rights and permissions granted to Esoteric Software
|
* Full irrevocable rights and permissions granted to Esoteric Software
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
@ -72,7 +71,12 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
get {
|
get {
|
||||||
if (_boneMesh == null) {
|
if (_boneMesh == null) {
|
||||||
_boneMesh = new Mesh();
|
_boneMesh = new Mesh();
|
||||||
_boneMesh.vertices = new Vector3[4]{Vector3.zero, new Vector3(-0.1f,0.1f,0), Vector3.up, new Vector3(0.1f,0.1f,0)};
|
_boneMesh.vertices = new Vector3[4] {
|
||||||
|
Vector3.zero,
|
||||||
|
new Vector3(-0.1f, 0.1f, 0),
|
||||||
|
Vector3.up,
|
||||||
|
new Vector3(0.1f, 0.1f, 0)
|
||||||
|
};
|
||||||
_boneMesh.uv = new Vector2[4];
|
_boneMesh.uv = new Vector2[4];
|
||||||
_boneMesh.triangles = new int[6]{0,1,2,2,3,0};
|
_boneMesh.triangles = new int[6]{0,1,2,2,3,0};
|
||||||
_boneMesh.RecalculateBounds();
|
_boneMesh.RecalculateBounds();
|
||||||
@ -82,8 +86,8 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
return _boneMesh;
|
return _boneMesh;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal static Mesh _boneMesh;
|
|
||||||
|
|
||||||
|
internal static Mesh _boneMesh;
|
||||||
|
|
||||||
public static Material boneMaterial {
|
public static Material boneMaterial {
|
||||||
get {
|
get {
|
||||||
@ -101,6 +105,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
return _boneMaterial;
|
return _boneMaterial;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Material _boneMaterial;
|
internal static Material _boneMaterial;
|
||||||
|
|
||||||
public static void Initialize () {
|
public static void Initialize () {
|
||||||
@ -125,19 +130,13 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
skeletonUtility = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-skeletonUtility.png");
|
skeletonUtility = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-skeletonUtility.png");
|
||||||
hingeChain = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-hingeChain.png");
|
hingeChain = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-hingeChain.png");
|
||||||
subMeshRenderer = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-subMeshRenderer.png");
|
subMeshRenderer = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-subMeshRenderer.png");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static string editorPath = "";
|
public static string editorPath = "";
|
||||||
public static string editorGUIPath = "";
|
public static string editorGUIPath = "";
|
||||||
|
|
||||||
static Dictionary<int, GameObject> skeletonRendererTable;
|
static Dictionary<int, GameObject> skeletonRendererTable;
|
||||||
static Dictionary<int, SkeletonUtilityBone> skeletonUtilityBoneTable;
|
static Dictionary<int, SkeletonUtilityBone> skeletonUtilityBoneTable;
|
||||||
|
|
||||||
public static float defaultScale = 0.01f;
|
public static float defaultScale = 0.01f;
|
||||||
public static float defaultMix = 0.2f;
|
public static float defaultMix = 0.2f;
|
||||||
public static string defaultShader = "Spine/Skeleton";
|
public static string defaultShader = "Spine/Skeleton";
|
||||||
@ -180,8 +179,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
r.width = 15;
|
r.width = 15;
|
||||||
|
|
||||||
GUI.Label(r, Icons.spine);
|
GUI.Label(r, Icons.spine);
|
||||||
}
|
} else if (skeletonUtilityBoneTable.ContainsKey(instanceId)) {
|
||||||
else if(skeletonUtilityBoneTable.ContainsKey(instanceId)){
|
|
||||||
Rect r = new Rect(selectionRect);
|
Rect r = new Rect(selectionRect);
|
||||||
r.x -= 26;
|
r.x -= 26;
|
||||||
|
|
||||||
@ -196,8 +194,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
|
|
||||||
if (skeletonUtilityBoneTable[instanceId].mode == SkeletonUtilityBone.Mode.Follow) {
|
if (skeletonUtilityBoneTable[instanceId].mode == SkeletonUtilityBone.Mode.Follow) {
|
||||||
GUI.DrawTexture(r, Icons.bone);
|
GUI.DrawTexture(r, Icons.bone);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
GUI.DrawTexture(r, Icons.poseBones);
|
GUI.DrawTexture(r, Icons.poseBones);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,8 +277,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
GameObject.Destroy(anim.gameObject);
|
GameObject.Destroy(anim.gameObject);
|
||||||
else
|
else
|
||||||
GameObject.DestroyImmediate(anim.gameObject);
|
GameObject.DestroyImmediate(anim.gameObject);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,11 +302,9 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
Dictionary<string, object> skeletonInfo = (Dictionary<string, object>)root["skeleton"];
|
Dictionary<string, object> skeletonInfo = (Dictionary<string, object>)root["skeleton"];
|
||||||
|
|
||||||
string spineVersion = (string)skeletonInfo["spine"];
|
string spineVersion = (string)skeletonInfo["spine"];
|
||||||
|
|
||||||
//TODO: reject old versions
|
//TODO: reject old versions
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static SkeletonDataAsset AutoIngestSpineProject (TextAsset spineJson, Object atlasSource = null) {
|
static SkeletonDataAsset AutoIngestSpineProject (TextAsset spineJson, Object atlasSource = null) {
|
||||||
@ -320,8 +314,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
if (atlasSource != null) {
|
if (atlasSource != null) {
|
||||||
if (atlasSource.GetType() == typeof(TextAsset)) {
|
if (atlasSource.GetType() == typeof(TextAsset)) {
|
||||||
atlasText = (TextAsset)atlasSource;
|
atlasText = (TextAsset)atlasSource;
|
||||||
}
|
} else if (atlasSource.GetType() == typeof(AtlasAsset)) {
|
||||||
else if(atlasSource.GetType() == typeof(AtlasAsset)){
|
|
||||||
atlasAsset = (AtlasAsset)atlasSource;
|
atlasAsset = (AtlasAsset)atlasSource;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -339,8 +332,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
bool abort = !EditorUtility.DisplayDialog("Atlas not Found", "Expecting " + spineJson.name + ".atlas\n" + "Press OK to select Atlas", "OK", "Abort");
|
bool abort = !EditorUtility.DisplayDialog("Atlas not Found", "Expecting " + spineJson.name + ".atlas\n" + "Press OK to select Atlas", "OK", "Abort");
|
||||||
if (abort) {
|
if (abort) {
|
||||||
//do nothing, let it error later
|
//do nothing, let it error later
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
string path = EditorUtility.OpenFilePanel("Find Atlas source...", Path.GetDirectoryName(Application.dataPath) + "/" + assetPath, "txt");
|
string path = EditorUtility.OpenFilePanel("Find Atlas source...", Path.GetDirectoryName(Application.dataPath) + "/" + assetPath, "txt");
|
||||||
if (path != "") {
|
if (path != "") {
|
||||||
path = path.Replace("\\", "/");
|
path = path.Replace("\\", "/");
|
||||||
@ -436,9 +428,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
return (AtlasAsset)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(AtlasAsset));
|
return (AtlasAsset)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(AtlasAsset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static SkeletonDataAsset IngestSpineProject (TextAsset spineJson, AtlasAsset atlasAsset = null) {
|
static SkeletonDataAsset IngestSpineProject (TextAsset spineJson, AtlasAsset atlasAsset = null) {
|
||||||
|
|
||||||
string primaryName = Path.GetFileNameWithoutExtension(spineJson.name);
|
string primaryName = Path.GetFileNameWithoutExtension(spineJson.name);
|
||||||
string assetPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(spineJson));
|
string assetPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(spineJson));
|
||||||
string filePath = assetPath + "/" + primaryName + "_SkeletonData.asset";
|
string filePath = assetPath + "/" + primaryName + "_SkeletonData.asset";
|
||||||
@ -458,15 +448,13 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
|
|
||||||
AssetDatabase.CreateAsset(skelDataAsset, filePath);
|
AssetDatabase.CreateAsset(skelDataAsset, filePath);
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
skelDataAsset.Reset();
|
skelDataAsset.Reset();
|
||||||
skelDataAsset.GetSkeletonData(true);
|
skelDataAsset.GetSkeletonData(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return skelDataAsset;
|
return skelDataAsset;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
EditorUtility.DisplayDialog("Error!", "Must specify both Spine JSON and Atlas TextAsset", "OK");
|
EditorUtility.DisplayDialog("Error!", "Must specify both Spine JSON and Atlas TextAsset", "OK");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -475,9 +463,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
[MenuItem("Assets/Spine/Spawn")]
|
[MenuItem("Assets/Spine/Spawn")]
|
||||||
static void SpawnAnimatedSkeleton () {
|
static void SpawnAnimatedSkeleton () {
|
||||||
Object[] arr = Selection.objects;
|
Object[] arr = Selection.objects;
|
||||||
|
|
||||||
foreach (Object o in arr) {
|
foreach (Object o in arr) {
|
||||||
|
|
||||||
string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(o));
|
string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(o));
|
||||||
string skinName = EditorPrefs.GetString(guid + "_lastSkin", "");
|
string skinName = EditorPrefs.GetString(guid + "_lastSkin", "");
|
||||||
|
|
||||||
@ -506,7 +492,6 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static SkeletonAnimation SpawnAnimatedSkeleton (SkeletonDataAsset skeletonDataAsset, Skin skin = null) {
|
public static SkeletonAnimation SpawnAnimatedSkeleton (SkeletonDataAsset skeletonDataAsset, Skin skin = null) {
|
||||||
|
|
||||||
GameObject go = new GameObject(skeletonDataAsset.name.Replace("_SkeletonData", ""), typeof(MeshFilter), typeof(MeshRenderer), typeof(SkeletonAnimation));
|
GameObject go = new GameObject(skeletonDataAsset.name.Replace("_SkeletonData", ""), typeof(MeshFilter), typeof(MeshRenderer), typeof(SkeletonAnimation));
|
||||||
SkeletonAnimation anim = go.GetComponent<SkeletonAnimation>();
|
SkeletonAnimation anim = go.GetComponent<SkeletonAnimation>();
|
||||||
anim.skeletonDataAsset = skeletonDataAsset;
|
anim.skeletonDataAsset = skeletonDataAsset;
|
||||||
@ -548,8 +533,4 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
|
|
||||||
return anim;
|
return anim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -42,19 +42,22 @@ public class SkeletonAnimation : SkeletonRenderer {
|
|||||||
public Spine.AnimationState state;
|
public Spine.AnimationState state;
|
||||||
|
|
||||||
public delegate void UpdateBonesDelegate (SkeletonAnimation skeleton);
|
public delegate void UpdateBonesDelegate (SkeletonAnimation skeleton);
|
||||||
|
|
||||||
public UpdateBonesDelegate UpdateLocal;
|
public UpdateBonesDelegate UpdateLocal;
|
||||||
public UpdateBonesDelegate UpdateWorld;
|
public UpdateBonesDelegate UpdateWorld;
|
||||||
public UpdateBonesDelegate UpdateComplete;
|
public UpdateBonesDelegate UpdateComplete;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private String _animationName;
|
private String
|
||||||
|
_animationName;
|
||||||
|
|
||||||
public String AnimationName {
|
public String AnimationName {
|
||||||
get {
|
get {
|
||||||
TrackEntry entry = state.GetCurrent(0);
|
TrackEntry entry = state.GetCurrent(0);
|
||||||
return entry == null ? null : entry.Animation.Name;
|
return entry == null ? null : entry.Animation.Name;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
if (_animationName == value) return;
|
if (_animationName == value)
|
||||||
|
return;
|
||||||
_animationName = value;
|
_animationName = value;
|
||||||
if (value == null || value.Length == 0)
|
if (value == null || value.Length == 0)
|
||||||
state.ClearTrack(0);
|
state.ClearTrack(0);
|
||||||
@ -65,7 +68,8 @@ public class SkeletonAnimation : SkeletonRenderer {
|
|||||||
|
|
||||||
public override void Reset () {
|
public override void Reset () {
|
||||||
base.Reset();
|
base.Reset();
|
||||||
if (!valid) return;
|
if (!valid)
|
||||||
|
return;
|
||||||
|
|
||||||
state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData());
|
state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData());
|
||||||
if (_animationName != null && _animationName.Length > 0) {
|
if (_animationName != null && _animationName.Length > 0) {
|
||||||
@ -79,7 +83,8 @@ public class SkeletonAnimation : SkeletonRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Update (float deltaTime) {
|
public virtual void Update (float deltaTime) {
|
||||||
if (!valid) return;
|
if (!valid)
|
||||||
|
return;
|
||||||
|
|
||||||
deltaTime *= timeScale;
|
deltaTime *= timeScale;
|
||||||
skeleton.Update(deltaTime);
|
skeleton.Update(deltaTime);
|
||||||
|
|||||||
@ -87,7 +87,8 @@ public class SkeletonDataAsset : ScriptableObject {
|
|||||||
stateData = new AnimationStateData(skeletonData);
|
stateData = new AnimationStateData(skeletonData);
|
||||||
stateData.DefaultMix = defaultMix;
|
stateData.DefaultMix = defaultMix;
|
||||||
for (int i = 0, n = fromAnimation.Length; i < n; i++) {
|
for (int i = 0, n = fromAnimation.Length; i < n; i++) {
|
||||||
if (fromAnimation[i].Length == 0 || toAnimation[i].Length == 0) continue;
|
if (fromAnimation[i].Length == 0 || toAnimation[i].Length == 0)
|
||||||
|
continue;
|
||||||
stateData.SetMix(fromAnimation[i], toAnimation[i], duration[i]);
|
stateData.SetMix(fromAnimation[i], toAnimation[i], duration[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,20 +39,18 @@ using Spine;
|
|||||||
public class SkeletonRenderer : MonoBehaviour {
|
public class SkeletonRenderer : MonoBehaviour {
|
||||||
|
|
||||||
public delegate void SkeletonRendererDelegate (SkeletonRenderer skeletonRenderer);
|
public delegate void SkeletonRendererDelegate (SkeletonRenderer skeletonRenderer);
|
||||||
public SkeletonRendererDelegate OnReset;
|
|
||||||
|
|
||||||
|
public SkeletonRendererDelegate OnReset;
|
||||||
[System.NonSerialized]
|
[System.NonSerialized]
|
||||||
public bool valid;
|
public bool valid;
|
||||||
[System.NonSerialized]
|
[System.NonSerialized]
|
||||||
public Skeleton skeleton;
|
public Skeleton skeleton;
|
||||||
|
|
||||||
public SkeletonDataAsset skeletonDataAsset;
|
public SkeletonDataAsset skeletonDataAsset;
|
||||||
public String initialSkinName;
|
public String initialSkinName;
|
||||||
public bool calculateNormals, calculateTangents;
|
public bool calculateNormals, calculateTangents;
|
||||||
public float zSpacing;
|
public float zSpacing;
|
||||||
public bool renderMeshes = true, immutableTriangles;
|
public bool renderMeshes = true, immutableTriangles;
|
||||||
public bool logErrors = false;
|
public bool logErrors = false;
|
||||||
|
|
||||||
private MeshFilter meshFilter;
|
private MeshFilter meshFilter;
|
||||||
private Mesh mesh, mesh1, mesh2;
|
private Mesh mesh, mesh1, mesh2;
|
||||||
private bool useMesh1;
|
private bool useMesh1;
|
||||||
@ -66,9 +64,12 @@ public class SkeletonRenderer : MonoBehaviour {
|
|||||||
private readonly List<Submesh> submeshes = new List<Submesh>();
|
private readonly List<Submesh> submeshes = new List<Submesh>();
|
||||||
|
|
||||||
public virtual void Reset () {
|
public virtual void Reset () {
|
||||||
if (meshFilter != null) meshFilter.sharedMesh = null;
|
if (meshFilter != null)
|
||||||
if (mesh != null) DestroyImmediate(mesh);
|
meshFilter.sharedMesh = null;
|
||||||
if (renderer != null) renderer.sharedMaterial = null;
|
if (mesh != null)
|
||||||
|
DestroyImmediate(mesh);
|
||||||
|
if (renderer != null)
|
||||||
|
renderer.sharedMaterial = null;
|
||||||
mesh = null;
|
mesh = null;
|
||||||
mesh1 = null;
|
mesh1 = null;
|
||||||
mesh2 = null;
|
mesh2 = null;
|
||||||
@ -89,7 +90,8 @@ public class SkeletonRenderer : MonoBehaviour {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SkeletonData skeletonData = skeletonDataAsset.GetSkeletonData(false);
|
SkeletonData skeletonData = skeletonDataAsset.GetSkeletonData(false);
|
||||||
if (skeletonData == null) return;
|
if (skeletonData == null)
|
||||||
|
return;
|
||||||
valid = true;
|
valid = true;
|
||||||
|
|
||||||
meshFilter = GetComponent<MeshFilter>();
|
meshFilter = GetComponent<MeshFilter>();
|
||||||
@ -100,7 +102,8 @@ public class SkeletonRenderer : MonoBehaviour {
|
|||||||
skeleton = new Skeleton(skeletonData);
|
skeleton = new Skeleton(skeletonData);
|
||||||
if (initialSkinName != null && initialSkinName.Length > 0 && initialSkinName != "default")
|
if (initialSkinName != null && initialSkinName.Length > 0 && initialSkinName != "default")
|
||||||
skeleton.SetSkin(initialSkinName);
|
skeleton.SetSkin(initialSkinName);
|
||||||
if(OnReset != null) OnReset(this);
|
if (OnReset != null)
|
||||||
|
OnReset(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Awake () {
|
public void Awake () {
|
||||||
@ -116,7 +119,8 @@ public class SkeletonRenderer : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public virtual void LateUpdate () {
|
public virtual void LateUpdate () {
|
||||||
if (!valid) return;
|
if (!valid)
|
||||||
|
return;
|
||||||
// Count vertices and submesh triangles.
|
// Count vertices and submesh triangles.
|
||||||
int vertexCount = 0;
|
int vertexCount = 0;
|
||||||
int submeshTriangleCount = 0, submeshFirstVertex = 0, submeshStartSlotIndex = 0;
|
int submeshTriangleCount = 0, submeshFirstVertex = 0, submeshStartSlotIndex = 0;
|
||||||
@ -137,7 +141,8 @@ public class SkeletonRenderer : MonoBehaviour {
|
|||||||
attachmentVertexCount = 4;
|
attachmentVertexCount = 4;
|
||||||
attachmentTriangleCount = 6;
|
attachmentTriangleCount = 6;
|
||||||
} else {
|
} else {
|
||||||
if (!renderMeshes) continue;
|
if (!renderMeshes)
|
||||||
|
continue;
|
||||||
if (attachment is MeshAttachment) {
|
if (attachment is MeshAttachment) {
|
||||||
MeshAttachment meshAttachment = (MeshAttachment)attachment;
|
MeshAttachment meshAttachment = (MeshAttachment)attachment;
|
||||||
rendererObject = meshAttachment.RendererObject;
|
rendererObject = meshAttachment.RendererObject;
|
||||||
@ -217,7 +222,8 @@ public class SkeletonRenderer : MonoBehaviour {
|
|||||||
color.r = (byte)(r * slot.r * regionAttachment.r * color.a);
|
color.r = (byte)(r * slot.r * regionAttachment.r * color.a);
|
||||||
color.g = (byte)(g * slot.g * regionAttachment.g * color.a);
|
color.g = (byte)(g * slot.g * regionAttachment.g * color.a);
|
||||||
color.b = (byte)(b * slot.b * regionAttachment.b * color.a);
|
color.b = (byte)(b * slot.b * regionAttachment.b * color.a);
|
||||||
if (slot.data.additiveBlending) color.a = 0;
|
if (slot.data.additiveBlending)
|
||||||
|
color.a = 0;
|
||||||
colors[vertexIndex] = color;
|
colors[vertexIndex] = color;
|
||||||
colors[vertexIndex + 1] = color;
|
colors[vertexIndex + 1] = color;
|
||||||
colors[vertexIndex + 2] = color;
|
colors[vertexIndex + 2] = color;
|
||||||
@ -231,18 +237,21 @@ public class SkeletonRenderer : MonoBehaviour {
|
|||||||
|
|
||||||
vertexIndex += 4;
|
vertexIndex += 4;
|
||||||
} else {
|
} else {
|
||||||
if (!renderMeshes) continue;
|
if (!renderMeshes)
|
||||||
|
continue;
|
||||||
if (attachment is MeshAttachment) {
|
if (attachment is MeshAttachment) {
|
||||||
MeshAttachment meshAttachment = (MeshAttachment)attachment;
|
MeshAttachment meshAttachment = (MeshAttachment)attachment;
|
||||||
int meshVertexCount = meshAttachment.vertices.Length;
|
int meshVertexCount = meshAttachment.vertices.Length;
|
||||||
if (tempVertices.Length < meshVertexCount) tempVertices = new float[meshVertexCount];
|
if (tempVertices.Length < meshVertexCount)
|
||||||
|
tempVertices = new float[meshVertexCount];
|
||||||
meshAttachment.ComputeWorldVertices(slot, tempVertices);
|
meshAttachment.ComputeWorldVertices(slot, tempVertices);
|
||||||
|
|
||||||
color.a = (byte)(a * slot.a * meshAttachment.a);
|
color.a = (byte)(a * slot.a * meshAttachment.a);
|
||||||
color.r = (byte)(r * slot.r * meshAttachment.r * color.a);
|
color.r = (byte)(r * slot.r * meshAttachment.r * color.a);
|
||||||
color.g = (byte)(g * slot.g * meshAttachment.g * color.a);
|
color.g = (byte)(g * slot.g * meshAttachment.g * color.a);
|
||||||
color.b = (byte)(b * slot.b * meshAttachment.b * color.a);
|
color.b = (byte)(b * slot.b * meshAttachment.b * color.a);
|
||||||
if (slot.data.additiveBlending) color.a = 0;
|
if (slot.data.additiveBlending)
|
||||||
|
color.a = 0;
|
||||||
|
|
||||||
float[] meshUVs = meshAttachment.uvs;
|
float[] meshUVs = meshAttachment.uvs;
|
||||||
float z = i * zSpacing;
|
float z = i * zSpacing;
|
||||||
@ -254,14 +263,16 @@ public class SkeletonRenderer : MonoBehaviour {
|
|||||||
} else if (attachment is SkinnedMeshAttachment) {
|
} else if (attachment is SkinnedMeshAttachment) {
|
||||||
SkinnedMeshAttachment meshAttachment = (SkinnedMeshAttachment)attachment;
|
SkinnedMeshAttachment meshAttachment = (SkinnedMeshAttachment)attachment;
|
||||||
int meshVertexCount = meshAttachment.uvs.Length;
|
int meshVertexCount = meshAttachment.uvs.Length;
|
||||||
if (tempVertices.Length < meshVertexCount) tempVertices = new float[meshVertexCount];
|
if (tempVertices.Length < meshVertexCount)
|
||||||
|
tempVertices = new float[meshVertexCount];
|
||||||
meshAttachment.ComputeWorldVertices(slot, tempVertices);
|
meshAttachment.ComputeWorldVertices(slot, tempVertices);
|
||||||
|
|
||||||
color.a = (byte)(a * slot.a * meshAttachment.a);
|
color.a = (byte)(a * slot.a * meshAttachment.a);
|
||||||
color.r = (byte)(r * slot.r * meshAttachment.r * color.a);
|
color.r = (byte)(r * slot.r * meshAttachment.r * color.a);
|
||||||
color.g = (byte)(g * slot.g * meshAttachment.g * color.a);
|
color.g = (byte)(g * slot.g * meshAttachment.g * color.a);
|
||||||
color.b = (byte)(b * slot.b * meshAttachment.b * color.a);
|
color.b = (byte)(b * slot.b * meshAttachment.b * color.a);
|
||||||
if (slot.data.additiveBlending) color.a = 0;
|
if (slot.data.additiveBlending)
|
||||||
|
color.a = 0;
|
||||||
|
|
||||||
float[] meshUVs = meshAttachment.uvs;
|
float[] meshUVs = meshAttachment.uvs;
|
||||||
float z = i * zSpacing;
|
float z = i * zSpacing;
|
||||||
|
|||||||
@ -32,7 +32,6 @@
|
|||||||
* Skeleton Utility created by Mitch Thompson
|
* Skeleton Utility created by Mitch Thompson
|
||||||
* Full irrevocable rights and permissions granted to Esoteric Software
|
* Full irrevocable rights and permissions granted to Esoteric Software
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
@ -72,9 +71,6 @@ public class SkeletonUtilityBoneInspector : Editor {
|
|||||||
canCreateHingeChain = CanCreateHingeChain();
|
canCreateHingeChain = CanCreateHingeChain();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Evaluates the flags.
|
|
||||||
/// </summary>
|
|
||||||
void EvaluateFlags () {
|
void EvaluateFlags () {
|
||||||
utilityBone = (SkeletonUtilityBone)target;
|
utilityBone = (SkeletonUtilityBone)target;
|
||||||
skeletonUtility = utilityBone.skeletonUtility;
|
skeletonUtility = utilityBone.skeletonUtility;
|
||||||
@ -82,8 +78,7 @@ public class SkeletonUtilityBoneInspector : Editor {
|
|||||||
if (Selection.objects.Length == 1) {
|
if (Selection.objects.Length == 1) {
|
||||||
containsFollows = utilityBone.mode == SkeletonUtilityBone.Mode.Follow;
|
containsFollows = utilityBone.mode == SkeletonUtilityBone.Mode.Follow;
|
||||||
containsOverrides = utilityBone.mode == SkeletonUtilityBone.Mode.Override;
|
containsOverrides = utilityBone.mode == SkeletonUtilityBone.Mode.Override;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
int boneCount = 0;
|
int boneCount = 0;
|
||||||
foreach (Object o in Selection.objects) {
|
foreach (Object o in Selection.objects) {
|
||||||
if (o is GameObject) {
|
if (o is GameObject) {
|
||||||
@ -104,8 +99,7 @@ public class SkeletonUtilityBoneInspector : Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnInspectorGUI ()
|
public override void OnInspectorGUI () {
|
||||||
{
|
|
||||||
serializedObject.Update();
|
serializedObject.Update();
|
||||||
|
|
||||||
EditorGUI.BeginChangeCheck();
|
EditorGUI.BeginChangeCheck();
|
||||||
@ -118,8 +112,10 @@ public class SkeletonUtilityBoneInspector : Editor {
|
|||||||
EditorGUI.BeginDisabledGroup(multiObject);
|
EditorGUI.BeginDisabledGroup(multiObject);
|
||||||
{
|
{
|
||||||
string str = boneName.stringValue;
|
string str = boneName.stringValue;
|
||||||
if(str == "") str = "<None>";
|
if (str == "")
|
||||||
if(multiObject) str = "<Multiple>";
|
str = "<None>";
|
||||||
|
if (multiObject)
|
||||||
|
str = "<Multiple>";
|
||||||
|
|
||||||
GUILayout.BeginHorizontal();
|
GUILayout.BeginHorizontal();
|
||||||
EditorGUILayout.PrefixLabel("Bone");
|
EditorGUILayout.PrefixLabel("Bone");
|
||||||
@ -147,8 +143,7 @@ public class SkeletonUtilityBoneInspector : Editor {
|
|||||||
{
|
{
|
||||||
EditorGUI.BeginChangeCheck();
|
EditorGUI.BeginChangeCheck();
|
||||||
EditorGUILayout.PropertyField(flipX);
|
EditorGUILayout.PropertyField(flipX);
|
||||||
if (EditorGUI.EndChangeCheck())
|
if (EditorGUI.EndChangeCheck()) {
|
||||||
{
|
|
||||||
FlipX(flipX.boolValue);
|
FlipX(flipX.boolValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,11 +183,9 @@ public class SkeletonUtilityBoneInspector : Editor {
|
|||||||
serializedObject.ApplyModifiedProperties();
|
serializedObject.ApplyModifiedProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlipX(bool state)
|
void FlipX (bool state) {
|
||||||
{
|
|
||||||
utilityBone.FlipX(state);
|
utilityBone.FlipX(state);
|
||||||
if (Application.isPlaying == false)
|
if (Application.isPlaying == false) {
|
||||||
{
|
|
||||||
skeletonUtility.skeletonAnimation.LateUpdate();
|
skeletonUtility.skeletonAnimation.LateUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,13 +204,11 @@ public class SkeletonUtilityBoneInspector : Editor {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TargetBoneSelected (object obj) {
|
void TargetBoneSelected (object obj) {
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
boneName.stringValue = "";
|
boneName.stringValue = "";
|
||||||
serializedObject.ApplyModifiedProperties();
|
serializedObject.ApplyModifiedProperties();
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
Bone bone = (Bone)obj;
|
Bone bone = (Bone)obj;
|
||||||
boneName.stringValue = bone.Data.Name;
|
boneName.stringValue = bone.Data.Name;
|
||||||
serializedObject.ApplyModifiedProperties();
|
serializedObject.ApplyModifiedProperties();
|
||||||
@ -235,8 +226,7 @@ public class SkeletonUtilityBoneInspector : Editor {
|
|||||||
foreach (SkeletonUtilityBone utilBone in newUtilityBones)
|
foreach (SkeletonUtilityBone utilBone in newUtilityBones)
|
||||||
SkeletonUtilityInspector.AttachIcon(utilBone);
|
SkeletonUtilityInspector.AttachIcon(utilBone);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
Bone bone = (Bone)obj;
|
Bone bone = (Bone)obj;
|
||||||
GameObject go = skeletonUtility.SpawnBone(bone, utilityBone.transform, utilityBone.mode, utilityBone.position, utilityBone.rotation, utilityBone.scale);
|
GameObject go = skeletonUtility.SpawnBone(bone, utilityBone.transform, utilityBone.mode, utilityBone.position, utilityBone.rotation, utilityBone.scale);
|
||||||
SkeletonUtilityInspector.AttachIcon(go.GetComponent<SkeletonUtilityBone>());
|
SkeletonUtilityInspector.AttachIcon(go.GetComponent<SkeletonUtilityBone>());
|
||||||
@ -254,13 +244,17 @@ public class SkeletonUtilityBoneInspector : Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CanCreateHingeChain () {
|
bool CanCreateHingeChain () {
|
||||||
if(utilityBone == null) return false;
|
if (utilityBone == null)
|
||||||
if(utilityBone.rigidbody != null) return false;
|
return false;
|
||||||
if(utilityBone.bone != null && utilityBone.bone.Children.Count == 0) return false;
|
if (utilityBone.rigidbody != null)
|
||||||
|
return false;
|
||||||
|
if (utilityBone.bone != null && utilityBone.bone.Children.Count == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
Rigidbody[] rigidbodies = utilityBone.GetComponentsInChildren<Rigidbody>();
|
Rigidbody[] rigidbodies = utilityBone.GetComponentsInChildren<Rigidbody>();
|
||||||
|
|
||||||
if(rigidbodies.Length > 0) return false;
|
if (rigidbodies.Length > 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -297,8 +291,7 @@ public class SkeletonUtilityBoneInspector : Editor {
|
|||||||
if (utilBone.bone.Data.Length == 0) {
|
if (utilBone.bone.Data.Length == 0) {
|
||||||
SphereCollider sphere = utilBone.gameObject.AddComponent<SphereCollider>();
|
SphereCollider sphere = utilBone.gameObject.AddComponent<SphereCollider>();
|
||||||
sphere.radius = 0.1f;
|
sphere.radius = 0.1f;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
float length = utilBone.bone.Data.Length;
|
float length = utilBone.bone.Data.Length;
|
||||||
BoxCollider box = utilBone.gameObject.AddComponent<BoxCollider>();
|
BoxCollider box = utilBone.gameObject.AddComponent<BoxCollider>();
|
||||||
box.size = new Vector3(length, length / 3, 0.2f);
|
box.size = new Vector3(length, length / 3, 0.2f);
|
||||||
|
|||||||
@ -32,9 +32,9 @@
|
|||||||
* Skeleton Utility created by Mitch Thompson
|
* Skeleton Utility created by Mitch Thompson
|
||||||
* Full irrevocable rights and permissions granted to Esoteric Software
|
* Full irrevocable rights and permissions granted to Esoteric Software
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
|
||||||
#if UNITY_4_3
|
#if UNITY_4_3
|
||||||
//nothing
|
//nothing
|
||||||
#else
|
#else
|
||||||
@ -66,7 +66,10 @@ public class SkeletonUtilityInspector : Editor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
typeof(EditorGUIUtility).InvokeMember("SetIconForObject", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic, null, null, new object[2]{ utilityBone.gameObject, icon});
|
typeof(EditorGUIUtility).InvokeMember("SetIconForObject", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic, null, null, new object[2] {
|
||||||
|
utilityBone.gameObject,
|
||||||
|
icon
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AttachIconsToChildren (Transform root) {
|
static void AttachIconsToChildren (Transform root) {
|
||||||
@ -78,8 +81,6 @@ public class SkeletonUtilityInspector : Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static SkeletonUtilityInspector () {
|
static SkeletonUtilityInspector () {
|
||||||
#if UNITY_4_3
|
#if UNITY_4_3
|
||||||
showSlots = false;
|
showSlots = false;
|
||||||
@ -89,13 +90,10 @@ public class SkeletonUtilityInspector : Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkeletonUtility skeletonUtility;
|
SkeletonUtility skeletonUtility;
|
||||||
|
|
||||||
Skeleton skeleton;
|
Skeleton skeleton;
|
||||||
SkeletonRenderer skeletonRenderer;
|
SkeletonRenderer skeletonRenderer;
|
||||||
Transform transform;
|
Transform transform;
|
||||||
bool isPrefab;
|
bool isPrefab;
|
||||||
|
|
||||||
|
|
||||||
Dictionary<Slot, List<Attachment>> attachmentTable = new Dictionary<Slot, List<Attachment>>();
|
Dictionary<Slot, List<Attachment>> attachmentTable = new Dictionary<Slot, List<Attachment>>();
|
||||||
|
|
||||||
|
|
||||||
@ -184,8 +182,7 @@ public class SkeletonUtilityInspector : Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnInspectorGUI ()
|
public override void OnInspectorGUI () {
|
||||||
{
|
|
||||||
if (isPrefab) {
|
if (isPrefab) {
|
||||||
GUILayout.Label(new GUIContent("Cannot edit Prefabs", SpineEditorUtilities.Icons.warning));
|
GUILayout.Label(new GUIContent("Cannot edit Prefabs", SpineEditorUtilities.Icons.warning));
|
||||||
return;
|
return;
|
||||||
@ -243,8 +240,7 @@ public class SkeletonUtilityInspector : Editor {
|
|||||||
|
|
||||||
if (slot.Attachment == attachment) {
|
if (slot.Attachment == attachment) {
|
||||||
GUI.contentColor = Color.white;
|
GUI.contentColor = Color.white;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
GUI.contentColor = Color.grey;
|
GUI.contentColor = Color.grey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,8 +259,7 @@ public class SkeletonUtilityInspector : Editor {
|
|||||||
if (!isAttached && swap) {
|
if (!isAttached && swap) {
|
||||||
slot.Attachment = attachment;
|
slot.Attachment = attachment;
|
||||||
skeletonRenderer.LateUpdate();
|
skeletonRenderer.LateUpdate();
|
||||||
}
|
} else if (isAttached && !swap) {
|
||||||
else if(isAttached && !swap){
|
|
||||||
slot.Attachment = null;
|
slot.Attachment = null;
|
||||||
skeletonRenderer.LateUpdate();
|
skeletonRenderer.LateUpdate();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,6 +59,7 @@ public class SkeletonUtility : MonoBehaviour {
|
|||||||
|
|
||||||
|
|
||||||
public delegate void SkeletonUtilityDelegate ();
|
public delegate void SkeletonUtilityDelegate ();
|
||||||
|
|
||||||
public event SkeletonUtilityDelegate OnReset;
|
public event SkeletonUtilityDelegate OnReset;
|
||||||
|
|
||||||
public Transform boneRoot;
|
public Transform boneRoot;
|
||||||
@ -78,18 +79,14 @@ public class SkeletonUtility : MonoBehaviour {
|
|||||||
|
|
||||||
[HideInInspector]
|
[HideInInspector]
|
||||||
public SkeletonRenderer skeletonRenderer;
|
public SkeletonRenderer skeletonRenderer;
|
||||||
|
|
||||||
[HideInInspector]
|
[HideInInspector]
|
||||||
public SkeletonAnimation skeletonAnimation;
|
public SkeletonAnimation skeletonAnimation;
|
||||||
|
|
||||||
[System.NonSerialized]
|
[System.NonSerialized]
|
||||||
public List<SkeletonUtilityBone> utilityBones = new List<SkeletonUtilityBone>();
|
public List<SkeletonUtilityBone> utilityBones = new List<SkeletonUtilityBone>();
|
||||||
|
|
||||||
[System.NonSerialized]
|
[System.NonSerialized]
|
||||||
public List<SkeletonUtilityConstraint> utilityConstraints = new List<SkeletonUtilityConstraint>();
|
public List<SkeletonUtilityConstraint> utilityConstraints = new List<SkeletonUtilityConstraint>();
|
||||||
// Dictionary<Bone, SkeletonUtilityBone> utilityBoneTable;
|
// Dictionary<Bone, SkeletonUtilityBone> utilityBoneTable;
|
||||||
|
|
||||||
|
|
||||||
protected bool hasTransformBones;
|
protected bool hasTransformBones;
|
||||||
protected bool hasUtilityConstraints;
|
protected bool hasUtilityConstraints;
|
||||||
protected bool needToReprocessBones;
|
protected bool needToReprocessBones;
|
||||||
@ -120,8 +117,6 @@ public class SkeletonUtility : MonoBehaviour {
|
|||||||
// CollectBones();
|
// CollectBones();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void OnDisable () {
|
void OnDisable () {
|
||||||
skeletonRenderer.OnReset -= HandleRendererReset;
|
skeletonRenderer.OnReset -= HandleRendererReset;
|
||||||
|
|
||||||
@ -207,8 +202,7 @@ public class SkeletonUtility : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
needToReprocessBones = false;
|
needToReprocessBones = false;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
utilityBones.Clear();
|
utilityBones.Clear();
|
||||||
utilityConstraints.Clear();
|
utilityConstraints.Clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,37 +44,32 @@ using Spine;
|
|||||||
[AddComponentMenu("Spine/SkeletonUtilityBone")]
|
[AddComponentMenu("Spine/SkeletonUtilityBone")]
|
||||||
public class SkeletonUtilityBone : MonoBehaviour {
|
public class SkeletonUtilityBone : MonoBehaviour {
|
||||||
|
|
||||||
public enum Mode { Follow, Override }
|
public enum Mode {
|
||||||
|
Follow,
|
||||||
|
Override
|
||||||
|
}
|
||||||
|
|
||||||
[System.NonSerialized]
|
[System.NonSerialized]
|
||||||
public bool valid;
|
public bool valid;
|
||||||
|
|
||||||
[System.NonSerialized]
|
[System.NonSerialized]
|
||||||
public SkeletonUtility skeletonUtility;
|
public SkeletonUtility skeletonUtility;
|
||||||
|
|
||||||
[System.NonSerialized]
|
[System.NonSerialized]
|
||||||
public Bone bone;
|
public Bone bone;
|
||||||
|
|
||||||
public Mode mode;
|
public Mode mode;
|
||||||
|
|
||||||
public bool zPosition = true;
|
public bool zPosition = true;
|
||||||
public bool position;
|
public bool position;
|
||||||
public bool rotation;
|
public bool rotation;
|
||||||
public bool scale;
|
public bool scale;
|
||||||
public bool flip;
|
public bool flip;
|
||||||
public bool flipX;
|
public bool flipX;
|
||||||
|
|
||||||
[Range(0f,1f)]
|
[Range(0f,1f)]
|
||||||
public float overrideAlpha = 1;
|
public float overrideAlpha = 1;
|
||||||
|
|
||||||
/// <summary>If a bone isn't set, boneName is used to find the bone.</summary>
|
/// <summary>If a bone isn't set, boneName is used to find the bone.</summary>
|
||||||
public String boneName;
|
public String boneName;
|
||||||
|
|
||||||
public Transform parentReference;
|
public Transform parentReference;
|
||||||
|
|
||||||
[HideInInspector]
|
[HideInInspector]
|
||||||
public bool transformLerpComplete;
|
public bool transformLerpComplete;
|
||||||
|
|
||||||
protected Transform cachedTransform;
|
protected Transform cachedTransform;
|
||||||
protected Transform skeletonTransform;
|
protected Transform skeletonTransform;
|
||||||
|
|
||||||
@ -83,13 +78,15 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
|||||||
return nonUniformScaleWarning;
|
return nonUniformScaleWarning;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool nonUniformScaleWarning;
|
private bool nonUniformScaleWarning;
|
||||||
|
|
||||||
public void Reset () {
|
public void Reset () {
|
||||||
bone = null;
|
bone = null;
|
||||||
cachedTransform = transform;
|
cachedTransform = transform;
|
||||||
valid = skeletonUtility != null && skeletonUtility.skeletonRenderer != null && skeletonUtility.skeletonRenderer.valid;
|
valid = skeletonUtility != null && skeletonUtility.skeletonRenderer != null && skeletonUtility.skeletonRenderer.valid;
|
||||||
if (!valid) return;
|
if (!valid)
|
||||||
|
return;
|
||||||
skeletonTransform = skeletonUtility.transform;
|
skeletonTransform = skeletonUtility.transform;
|
||||||
|
|
||||||
skeletonUtility.OnReset -= HandleOnReset;
|
skeletonUtility.OnReset -= HandleOnReset;
|
||||||
@ -109,8 +106,7 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
|||||||
skeletonUtility.OnReset += HandleOnReset;
|
skeletonUtility.OnReset += HandleOnReset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleOnReset ()
|
void HandleOnReset () {
|
||||||
{
|
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +128,8 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
|||||||
Spine.Skeleton skeleton = skeletonUtility.skeletonRenderer.skeleton;
|
Spine.Skeleton skeleton = skeletonUtility.skeletonRenderer.skeleton;
|
||||||
|
|
||||||
if (bone == null) {
|
if (bone == null) {
|
||||||
if (boneName == null || boneName.Length == 0) return;
|
if (boneName == null || boneName.Length == 0)
|
||||||
|
return;
|
||||||
bone = skeleton.FindBone(boneName);
|
bone = skeleton.FindBone(boneName);
|
||||||
if (bone == null) {
|
if (bone == null) {
|
||||||
Debug.LogError("Bone not found: " + boneName, this);
|
Debug.LogError("Bone not found: " + boneName, this);
|
||||||
@ -145,14 +142,12 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
|||||||
float skeletonFlipRotation = (skeleton.flipX ^ skeleton.flipY) ? -1f : 1f;
|
float skeletonFlipRotation = (skeleton.flipX ^ skeleton.flipY) ? -1f : 1f;
|
||||||
|
|
||||||
float flipCompensation = 0;
|
float flipCompensation = 0;
|
||||||
if (flip && (flipX || ( flipX != bone.flipX)) && bone.parent != null)
|
if (flip && (flipX || (flipX != bone.flipX)) && bone.parent != null) {
|
||||||
{
|
|
||||||
flipCompensation = bone.parent.WorldRotation * -2;
|
flipCompensation = bone.parent.WorldRotation * -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == Mode.Follow) {
|
if (mode == Mode.Follow) {
|
||||||
if (flip)
|
if (flip) {
|
||||||
{
|
|
||||||
flipX = bone.flipX;
|
flipX = bone.flipX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,15 +159,12 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
|||||||
if (rotation) {
|
if (rotation) {
|
||||||
|
|
||||||
if (bone.Data.InheritRotation) {
|
if (bone.Data.InheritRotation) {
|
||||||
if (bone.FlipX)
|
if (bone.FlipX) {
|
||||||
{
|
|
||||||
cachedTransform.localRotation = Quaternion.Euler(0, 180, bone.rotationIK - flipCompensation);
|
cachedTransform.localRotation = Quaternion.Euler(0, 180, bone.rotationIK - flipCompensation);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
cachedTransform.localRotation = Quaternion.Euler(0, 0, bone.rotationIK);
|
cachedTransform.localRotation = Quaternion.Euler(0, 0, bone.rotationIK);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
Vector3 euler = skeletonTransform.rotation.eulerAngles;
|
Vector3 euler = skeletonTransform.rotation.eulerAngles;
|
||||||
cachedTransform.rotation = Quaternion.Euler(euler.x, euler.y, skeletonTransform.rotation.eulerAngles.z + (bone.worldRotation * skeletonFlipRotation));
|
cachedTransform.rotation = Quaternion.Euler(euler.x, euler.y, skeletonTransform.rotation.eulerAngles.z + (bone.worldRotation * skeletonFlipRotation));
|
||||||
}
|
}
|
||||||
@ -185,8 +177,7 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
|||||||
nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
|
nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else if (mode == Mode.Override) {
|
||||||
else if(mode == Mode.Override){
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -203,8 +194,7 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
|||||||
float angle = Mathf.LerpAngle(bone.Rotation, cachedTransform.localRotation.eulerAngles.z, overrideAlpha) + flipCompensation;
|
float angle = Mathf.LerpAngle(bone.Rotation, cachedTransform.localRotation.eulerAngles.z, overrideAlpha) + flipCompensation;
|
||||||
|
|
||||||
if (flip) {
|
if (flip) {
|
||||||
if ((!flipX && bone.flipX))
|
if ((!flipX && bone.flipX)) {
|
||||||
{
|
|
||||||
angle -= flipCompensation;
|
angle -= flipCompensation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,12 +215,10 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
|||||||
nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
|
nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flip)
|
if (flip) {
|
||||||
{
|
|
||||||
bone.flipX = flipX;
|
bone.flipX = flipX;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
|
|
||||||
if (transformLerpComplete)
|
if (transformLerpComplete)
|
||||||
return;
|
return;
|
||||||
@ -244,10 +232,8 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
|||||||
if (rotation) {
|
if (rotation) {
|
||||||
float angle = Mathf.LerpAngle(bone.Rotation, Quaternion.LookRotation(flipX ? Vector3.forward * -1 : Vector3.forward, parentReference.InverseTransformDirection(cachedTransform.up)).eulerAngles.z, overrideAlpha) + flipCompensation;
|
float angle = Mathf.LerpAngle(bone.Rotation, Quaternion.LookRotation(flipX ? Vector3.forward * -1 : Vector3.forward, parentReference.InverseTransformDirection(cachedTransform.up)).eulerAngles.z, overrideAlpha) + flipCompensation;
|
||||||
|
|
||||||
if (flip)
|
if (flip) {
|
||||||
{
|
if ((!flipX && bone.flipX)) {
|
||||||
if ((!flipX && bone.flipX))
|
|
||||||
{
|
|
||||||
angle -= flipCompensation;
|
angle -= flipCompensation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,8 +255,7 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
|||||||
nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
|
nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flip)
|
if (flip) {
|
||||||
{
|
|
||||||
bone.flipX = flipX;
|
bone.flipX = flipX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,18 +265,13 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FlipX(bool state)
|
public void FlipX (bool state) {
|
||||||
{
|
if (state != flipX) {
|
||||||
if (state != flipX)
|
|
||||||
{
|
|
||||||
flipX = state;
|
flipX = state;
|
||||||
if (flipX && Mathf.Abs(transform.localRotation.eulerAngles.y) > 90)
|
if (flipX && Mathf.Abs(transform.localRotation.eulerAngles.y) > 90) {
|
||||||
{
|
|
||||||
skeletonUtility.skeletonAnimation.LateUpdate();
|
skeletonUtility.skeletonAnimation.LateUpdate();
|
||||||
return;
|
return;
|
||||||
}
|
} else if (!flipX && Mathf.Abs(transform.localRotation.eulerAngles.y) < 90) {
|
||||||
else if (!flipX && Mathf.Abs(transform.localRotation.eulerAngles.y) < 90)
|
|
||||||
{
|
|
||||||
skeletonUtility.skeletonAnimation.LateUpdate();
|
skeletonUtility.skeletonAnimation.LateUpdate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,14 +7,11 @@ public class SkeletonUtilityEyeConstraint : SkeletonUtilityConstraint {
|
|||||||
public float radius = 0.5f;
|
public float radius = 0.5f;
|
||||||
public Transform target;
|
public Transform target;
|
||||||
public Vector3 targetPosition;
|
public Vector3 targetPosition;
|
||||||
|
|
||||||
public float speed = 10;
|
public float speed = 10;
|
||||||
|
|
||||||
Vector3[] origins;
|
Vector3[] origins;
|
||||||
Vector3 centerPoint;
|
Vector3 centerPoint;
|
||||||
|
|
||||||
protected override void OnEnable ()
|
protected override void OnEnable () {
|
||||||
{
|
|
||||||
if (!Application.isPlaying)
|
if (!Application.isPlaying)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -30,16 +27,14 @@ public class SkeletonUtilityEyeConstraint : SkeletonUtilityConstraint {
|
|||||||
centerPoint = centerBounds.center;
|
centerPoint = centerBounds.center;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDisable ()
|
protected override void OnDisable () {
|
||||||
{
|
|
||||||
if (!Application.isPlaying)
|
if (!Application.isPlaying)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
base.OnDisable();
|
base.OnDisable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DoUpdate ()
|
public override void DoUpdate () {
|
||||||
{
|
|
||||||
|
|
||||||
if (target != null)
|
if (target != null)
|
||||||
targetPosition = target.position;
|
targetPosition = target.position;
|
||||||
|
|||||||
@ -38,18 +38,15 @@ public class SkeletonUtilityGroundConstraint : SkeletonUtilityConstraint {
|
|||||||
float hitY;
|
float hitY;
|
||||||
float lastHitY;
|
float lastHitY;
|
||||||
|
|
||||||
protected override void OnEnable ()
|
protected override void OnEnable () {
|
||||||
{
|
|
||||||
base.OnEnable();
|
base.OnEnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDisable ()
|
protected override void OnDisable () {
|
||||||
{
|
|
||||||
base.OnDisable();
|
base.OnDisable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DoUpdate()
|
public override void DoUpdate () {
|
||||||
{
|
|
||||||
rayOrigin = transform.position + new Vector3(castOffset, castDistance, 0);
|
rayOrigin = transform.position + new Vector3(castOffset, castDistance, 0);
|
||||||
|
|
||||||
hitY = float.MinValue;
|
hitY = float.MinValue;
|
||||||
@ -63,8 +60,7 @@ public class SkeletonUtilityGroundConstraint : SkeletonUtilityConstraint {
|
|||||||
#else
|
#else
|
||||||
hit = Physics2D.CircleCast(rayOrigin, castRadius, rayDir, castDistance + groundOffset, groundMask);
|
hit = Physics2D.CircleCast(rayOrigin, castRadius, rayDir, castDistance + groundOffset, groundMask);
|
||||||
#endif
|
#endif
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
hit = Physics2D.Raycast(rayOrigin, rayDir, castDistance + groundOffset, groundMask);
|
hit = Physics2D.Raycast(rayOrigin, rayDir, castDistance + groundOffset, groundMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,20 +69,17 @@ public class SkeletonUtilityGroundConstraint : SkeletonUtilityConstraint {
|
|||||||
if (Application.isPlaying) {
|
if (Application.isPlaying) {
|
||||||
hitY = Mathf.MoveTowards(lastHitY, hitY, adjustSpeed * Time.deltaTime);
|
hitY = Mathf.MoveTowards(lastHitY, hitY, adjustSpeed * Time.deltaTime);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
if (Application.isPlaying)
|
if (Application.isPlaying)
|
||||||
hitY = Mathf.MoveTowards(lastHitY, transform.position.y, adjustSpeed * Time.deltaTime);
|
hitY = Mathf.MoveTowards(lastHitY, transform.position.y, adjustSpeed * Time.deltaTime);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
RaycastHit hit;
|
RaycastHit hit;
|
||||||
bool validHit = false;
|
bool validHit = false;
|
||||||
|
|
||||||
if (useRadius) {
|
if (useRadius) {
|
||||||
validHit = Physics.SphereCast(rayOrigin, castRadius, rayDir, out hit, castDistance + groundOffset, groundMask);
|
validHit = Physics.SphereCast(rayOrigin, castRadius, rayDir, out hit, castDistance + groundOffset, groundMask);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
validHit = Physics.Raycast(rayOrigin, rayDir, out hit, castDistance + groundOffset, groundMask);
|
validHit = Physics.Raycast(rayOrigin, rayDir, out hit, castDistance + groundOffset, groundMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,8 +88,7 @@ public class SkeletonUtilityGroundConstraint : SkeletonUtilityConstraint {
|
|||||||
if (Application.isPlaying) {
|
if (Application.isPlaying) {
|
||||||
hitY = Mathf.MoveTowards(lastHitY, hitY, adjustSpeed * Time.deltaTime);
|
hitY = Mathf.MoveTowards(lastHitY, hitY, adjustSpeed * Time.deltaTime);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
if (Application.isPlaying)
|
if (Application.isPlaying)
|
||||||
hitY = Mathf.MoveTowards(lastHitY, transform.position.y, adjustSpeed * Time.deltaTime);
|
hitY = Mathf.MoveTowards(lastHitY, transform.position.y, adjustSpeed * Time.deltaTime);
|
||||||
}
|
}
|
||||||
@ -110,7 +102,6 @@ public class SkeletonUtilityGroundConstraint : SkeletonUtilityConstraint {
|
|||||||
utilBone.bone.Y = transform.localPosition.y;
|
utilBone.bone.Y = transform.localPosition.y;
|
||||||
|
|
||||||
lastHitY = hitY;
|
lastHitY = hitY;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDrawGizmos () {
|
void OnDrawGizmos () {
|
||||||
@ -123,8 +114,6 @@ public class SkeletonUtilityGroundConstraint : SkeletonUtilityConstraint {
|
|||||||
Gizmos.DrawLine(new Vector3(clearEnd.x - castRadius, clearEnd.y, clearEnd.z), new Vector3(clearEnd.x + castRadius, clearEnd.y, clearEnd.z));
|
Gizmos.DrawLine(new Vector3(clearEnd.x - castRadius, clearEnd.y, clearEnd.z), new Vector3(clearEnd.x + castRadius, clearEnd.y, clearEnd.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Gizmos.color = Color.red;
|
Gizmos.color = Color.red;
|
||||||
Gizmos.DrawLine(hitEnd, clearEnd);
|
Gizmos.DrawLine(hitEnd, clearEnd);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,9 +3,7 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public class SkeletonUtilityKinematicShadow : MonoBehaviour {
|
public class SkeletonUtilityKinematicShadow : MonoBehaviour {
|
||||||
|
|
||||||
public bool hideShadow = true;
|
public bool hideShadow = true;
|
||||||
|
|
||||||
Dictionary<Transform, Transform> shadowTable;
|
Dictionary<Transform, Transform> shadowTable;
|
||||||
GameObject shadowRoot;
|
GameObject shadowRoot;
|
||||||
|
|
||||||
|
|||||||
@ -3,16 +3,12 @@ using System.Collections;
|
|||||||
|
|
||||||
[ExecuteInEditMode]
|
[ExecuteInEditMode]
|
||||||
public class SkeletonUtilitySubmeshRenderer : MonoBehaviour {
|
public class SkeletonUtilitySubmeshRenderer : MonoBehaviour {
|
||||||
|
|
||||||
public Renderer parentRenderer;
|
public Renderer parentRenderer;
|
||||||
|
|
||||||
[System.NonSerialized]
|
[System.NonSerialized]
|
||||||
public Mesh mesh;
|
public Mesh mesh;
|
||||||
|
|
||||||
public int submeshIndex = 0;
|
public int submeshIndex = 0;
|
||||||
public int sortingOrder = 0;
|
public int sortingOrder = 0;
|
||||||
public int sortingLayerID = 0;
|
public int sortingLayerID = 0;
|
||||||
|
|
||||||
public Material hiddenPassMaterial;
|
public Material hiddenPassMaterial;
|
||||||
Renderer cachedRenderer;
|
Renderer cachedRenderer;
|
||||||
MeshFilter filter;
|
MeshFilter filter;
|
||||||
@ -62,8 +58,7 @@ public class SkeletonUtilitySubmeshRenderer : MonoBehaviour {
|
|||||||
if (mesh == null || submeshIndex > mesh.subMeshCount - 1) {
|
if (mesh == null || submeshIndex > mesh.subMeshCount - 1) {
|
||||||
cachedRenderer.enabled = false;
|
cachedRenderer.enabled = false;
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
renderer.enabled = true;
|
renderer.enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +90,6 @@ public class SkeletonUtilitySubmeshRenderer : MonoBehaviour {
|
|||||||
cachedRenderer.sharedMaterials = sharedMaterials;
|
cachedRenderer.sharedMaterials = sharedMaterials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cachedRenderer.sortingLayerID = sortingLayerID;
|
cachedRenderer.sortingLayerID = sortingLayerID;
|
||||||
cachedRenderer.sortingOrder = sortingOrder;
|
cachedRenderer.sortingOrder = sortingOrder;
|
||||||
}
|
}
|
||||||
|
|||||||
28
spine-unity/Spine.mdpolicy
Normal file
28
spine-unity/Spine.mdpolicy
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PolicySet name="Spine">
|
||||||
|
<TextStylePolicy inheritsSet="Mono" inheritsScope="text/plain" scope="text/x-csharp">
|
||||||
|
<FileWidth>130</FileWidth>
|
||||||
|
<TabWidth>3</TabWidth>
|
||||||
|
<IndentWidth>3</IndentWidth>
|
||||||
|
</TextStylePolicy>
|
||||||
|
<CSharpFormattingPolicy inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp">
|
||||||
|
<IndentNamespaceBody>False</IndentNamespaceBody>
|
||||||
|
<AlignEmbeddedUsingStatements>False</AlignEmbeddedUsingStatements>
|
||||||
|
<AlignEmbeddedIfStatements>False</AlignEmbeddedIfStatements>
|
||||||
|
<NamespaceBraceStyle>EndOfLine</NamespaceBraceStyle>
|
||||||
|
<ClassBraceStyle>EndOfLine</ClassBraceStyle>
|
||||||
|
<InterfaceBraceStyle>EndOfLine</InterfaceBraceStyle>
|
||||||
|
<StructBraceStyle>EndOfLine</StructBraceStyle>
|
||||||
|
<EnumBraceStyle>EndOfLine</EnumBraceStyle>
|
||||||
|
<MethodBraceStyle>EndOfLine</MethodBraceStyle>
|
||||||
|
<ConstructorBraceStyle>EndOfLine</ConstructorBraceStyle>
|
||||||
|
<DestructorBraceStyle>EndOfLine</DestructorBraceStyle>
|
||||||
|
<ElseIfNewLinePlacement>SameLine</ElseIfNewLinePlacement>
|
||||||
|
<BeforeMethodCallParentheses>False</BeforeMethodCallParentheses>
|
||||||
|
<AfterDelegateDeclarationParameterComma>True</AfterDelegateDeclarationParameterComma>
|
||||||
|
<NewParentheses>False</NewParentheses>
|
||||||
|
<SpacesBeforeBrackets>False</SpacesBeforeBrackets>
|
||||||
|
<BlankLinesBeforeUsings>1</BlankLinesBeforeUsings>
|
||||||
|
<BlankLinesBeforeFirstDeclaration>1</BlankLinesBeforeFirstDeclaration>
|
||||||
|
</CSharpFormattingPolicy>
|
||||||
|
</PolicySet>
|
||||||
Loading…
x
Reference in New Issue
Block a user