Pārlūkot izejas kodu

[unity] Sample scripts now use properties.

pharan 8 gadi atpakaļ
vecāks
revīzija
986e74f62b

+ 1 - 1
spine-unity/Assets/Examples/Getting Started/Scripts/BasicPlatformerController.cs

@@ -93,7 +93,7 @@ namespace Spine.Unity.Examples {
 
 		void Start () {
 			// Register a callback for Spine Events (in this case, Footstep)
-			skeletonAnimation.state.Event += HandleEvent;
+			skeletonAnimation.AnimationState.Event += HandleEvent;
 		}
 
 		void HandleEvent (Spine.TrackEntry trackEntry, Spine.Event e) {

+ 2 - 2
spine-unity/Assets/Examples/Getting Started/Scripts/SpineBeginnerTwo.cs

@@ -59,8 +59,8 @@ namespace Spine.Unity.Examples {
 		void Start () {
 			// Make sure you get these AnimationState and Skeleton references in Start or Later. Getting and using them in Awake is not guaranteed by default execution order.
 			skeletonAnimation = GetComponent<SkeletonAnimation>();
-			spineAnimationState = skeletonAnimation.state;
-			skeleton = skeletonAnimation.skeleton;
+			spineAnimationState = skeletonAnimation.AnimationState;
+			skeleton = skeletonAnimation.Skeleton;
 
 			StartCoroutine(DoDemoRoutine());
 		}

+ 1 - 1
spine-unity/Assets/Examples/Getting Started/Scripts/SpineBlinkPlayer.cs

@@ -44,7 +44,7 @@ namespace Spine.Unity.Examples {
 		IEnumerator Start () {
 			var skeletonAnimation = GetComponent<SkeletonAnimation>(); if (skeletonAnimation == null) yield break;
 			while (true) {
-				skeletonAnimation.state.SetAnimation(SpineBlinkPlayer.BlinkTrack, blinkAnimation, false);
+				skeletonAnimation.AnimationState.SetAnimation(SpineBlinkPlayer.BlinkTrack, blinkAnimation, false);
 				yield return new WaitForSeconds(Random.Range(minimumDelay, maximumDelay));
 			}
 		}

+ 5 - 5
spine-unity/Assets/Examples/Getting Started/Scripts/SpineboyBeginnerView.cs

@@ -57,7 +57,7 @@ namespace Spine.Unity.Examples {
 		void Start () {
 			if (skeletonAnimation == null) return;
 			model.ShootEvent += PlayShoot;
-			skeletonAnimation.state.Event += HandleEvent;
+			skeletonAnimation.AnimationState.Event += HandleEvent;
 		}
 
 		void HandleEvent (Spine.TrackEntry trackEntry, Spine.Event e) {
@@ -104,7 +104,7 @@ namespace Spine.Unity.Examples {
 				}
 			}
 
-			skeletonAnimation.state.SetAnimation(0, nextAnimation, true);
+			skeletonAnimation.AnimationState.SetAnimation(0, nextAnimation, true);
 		}
 
 		void PlayFootstepSound () {
@@ -114,7 +114,7 @@ namespace Spine.Unity.Examples {
 
 		[ContextMenu("Check Tracks")]
 		void CheckTracks () {
-			var state = skeletonAnimation.state;
+			var state = skeletonAnimation.AnimationState;
 			Debug.Log(state.GetCurrent(0));
 			Debug.Log(state.GetCurrent(1));
 		}
@@ -122,7 +122,7 @@ namespace Spine.Unity.Examples {
 		#region Transient Actions
 		public void PlayShoot () {
 			// Play the shoot animation on track 1.
-			skeletonAnimation.state.SetAnimation(1, shoot, false);
+			skeletonAnimation.AnimationState.SetAnimation(1, shoot, false);
 			//skeletonAnimation.state.AddEmptyAnimation(1, 0.1f, 0f);
 			gunSource.pitch = GetRandomPitch(gunsoundPitchOffset);
 			gunSource.Play();
@@ -131,7 +131,7 @@ namespace Spine.Unity.Examples {
 		}
 
 		public void Turn (bool facingLeft) {
-			skeletonAnimation.skeleton.FlipX = facingLeft;
+			skeletonAnimation.Skeleton.FlipX = facingLeft;
 			// Maybe play a transient turning animation too, then call ChangeStableAnimation.
 		}
 		#endregion

+ 3 - 3
spine-unity/Assets/Examples/Scripts/AttackSpineboy.cs

@@ -47,13 +47,13 @@ namespace Spine.Unity.Examples {
 				healthText.text = currentHealth + "/" + maxHealth;
 
 				if (currentHealth > 0) {
-					spineboy.state.SetAnimation(0, "hit", false);
-					spineboy.state.AddAnimation(0, "idle", true, 0);
+					spineboy.AnimationState.SetAnimation(0, "hit", false);
+					spineboy.AnimationState.AddAnimation(0, "idle", true, 0);
 					gauge.fillPercent = (float)currentHealth/(float)maxHealth;
 				} else {
 					if (currentHealth >= 0) {
 						gauge.fillPercent = 0;
-						spineboy.state.SetAnimation(0, "death", false).TrackEnd = float.PositiveInfinity;
+						spineboy.AnimationState.SetAnimation(0, "death", false).TrackEnd = float.PositiveInfinity;
 					}
 				}
 			}

+ 4 - 4
spine-unity/Assets/Examples/Scripts/FootSoldierExample.cs

@@ -80,11 +80,11 @@ namespace Spine.Unity.Examples {
 			} else {
 				if (Input.GetKey(rightKey)) {
 					skeletonAnimation.AnimationName = moveAnimation;
-					skeletonAnimation.skeleton.FlipX = false;
+					skeletonAnimation.Skeleton.FlipX = false;
 					transform.Translate(moveSpeed * Time.deltaTime, 0, 0);
 				} else if(Input.GetKey(leftKey)) {
 					skeletonAnimation.AnimationName = moveAnimation;
-					skeletonAnimation.skeleton.FlipX = true;
+					skeletonAnimation.Skeleton.FlipX = true;
 					transform.Translate(-moveSpeed * Time.deltaTime, 0, 0);
 				} else {
 					skeletonAnimation.AnimationName = idleAnimation;
@@ -95,9 +95,9 @@ namespace Spine.Unity.Examples {
 		IEnumerator Blink() {
 			while (true) {
 				yield return new WaitForSeconds(Random.Range(0.25f, 3f));
-				skeletonAnimation.skeleton.SetAttachment(eyesSlot, blinkAttachment);
+				skeletonAnimation.Skeleton.SetAttachment(eyesSlot, blinkAttachment);
 				yield return new WaitForSeconds(blinkDuration);
-				skeletonAnimation.skeleton.SetAttachment(eyesSlot, eyesOpenAttachment);
+				skeletonAnimation.Skeleton.SetAttachment(eyesSlot, eyesOpenAttachment);
 			}
 		}
 	}

+ 6 - 6
spine-unity/Assets/Examples/Scripts/Goblins.cs

@@ -43,7 +43,7 @@ namespace Spine.Unity.Examples {
 		
 		public void Start () {
 			skeletonAnimation = GetComponent<SkeletonAnimation>();
-			headBone = skeletonAnimation.skeleton.FindBone("head");
+			headBone = skeletonAnimation.Skeleton.FindBone("head");
 			skeletonAnimation.UpdateLocal += UpdateLocal;
 		}
 
@@ -53,16 +53,16 @@ namespace Spine.Unity.Examples {
 		}
 		
 		public void OnMouseDown () {
-			skeletonAnimation.skeleton.SetSkin(girlSkin ? "goblin" : "goblingirl");
-			skeletonAnimation.skeleton.SetSlotsToSetupPose();
+			skeletonAnimation.Skeleton.SetSkin(girlSkin ? "goblin" : "goblingirl");
+			skeletonAnimation.Skeleton.SetSlotsToSetupPose();
 			
 			girlSkin = !girlSkin;
 			
 			if (girlSkin) {
-				skeletonAnimation.skeleton.SetAttachment("right hand item", null);
-				skeletonAnimation.skeleton.SetAttachment("left hand item", "spear");
+				skeletonAnimation.Skeleton.SetAttachment("right hand item", null);
+				skeletonAnimation.Skeleton.SetAttachment("left hand item", "spear");
 			} else
-				skeletonAnimation.skeleton.SetAttachment("left hand item", "dagger");
+				skeletonAnimation.Skeleton.SetAttachment("left hand item", "dagger");
 		}
 	}
 }

+ 1 - 1
spine-unity/Assets/Examples/Scripts/MixAndMatch.cs

@@ -76,7 +76,7 @@ namespace Spine.Unity.Examples {
 			// Case 1: Create an attachment from an atlas.
 			RegionAttachment newHand = handSource.GetAtlas().FindRegion(handRegion).ToRegionAttachment("new hand");
 			newHand.SetPositionOffset(newHandOffset);
-			newHand.rotation = newHandRotation;
+			newHand.Rotation = newHandRotation;
 			newHand.UpdateOffset();
 			int handSlotIndex = skeleton.FindSlotIndex(handSlot);
 			handTexture = newHand.GetRegion().ToTexture();

+ 8 - 8
spine-unity/Assets/Examples/Scripts/Spineboy.cs

@@ -29,7 +29,6 @@
  *****************************************************************************/
 
 using UnityEngine;
-
 using Spine;
 using Spine.Unity;
 
@@ -39,21 +38,22 @@ namespace Spine.Unity.Examples {
 
 		public void Start () {
 			skeletonAnimation = GetComponent<SkeletonAnimation>(); // Get the SkeletonAnimation component for the GameObject this script is attached to.
+			var animationState = skeletonAnimation.AnimationState;
 
-			skeletonAnimation.state.Event += HandleEvent;; // Call our method any time an animation fires an event.
-			skeletonAnimation.state.End += (entry) => Debug.Log("start: " + entry.trackIndex); // A lambda can be used for the callback instead of a method.
+			animationState.Event += HandleEvent;; // Call our method any time an animation fires an event.
+			animationState.End += (entry) => Debug.Log("start: " + entry.TrackIndex); // A lambda can be used for the callback instead of a method.
 
-			skeletonAnimation.state.AddAnimation(0, "jump", false, 2);	// Queue jump to be played on track 0 two seconds after the starting animation.
-			skeletonAnimation.state.AddAnimation(0, "run", true, 0); // Queue walk to be looped on track 0 after the jump animation.
+			animationState.AddAnimation(0, "jump", false, 2);	// Queue jump to be played on track 0 two seconds after the starting animation.
+			animationState.AddAnimation(0, "run", true, 0); // Queue walk to be looped on track 0 after the jump animation.
 		}
 
 		void HandleEvent (TrackEntry trackEntry, Spine.Event e) {
-			Debug.Log(trackEntry.trackIndex + " " + trackEntry.animation.name + ": event " + e + ", " + e.Int);
+			Debug.Log(trackEntry.TrackIndex + " " + trackEntry.Animation.Name + ": event " + e + ", " + e.Int);
 		}
 
 		public void OnMouseDown () {
-			skeletonAnimation.state.SetAnimation(0, "jump", false); // Set jump to be played on track 0 immediately.
-			skeletonAnimation.state.AddAnimation(0, "run", true, 0); // Queue walk to be looped on track 0 after the jump animation.
+			skeletonAnimation.AnimationState.SetAnimation(0, "jump", false); // Set jump to be played on track 0 immediately.
+			skeletonAnimation.AnimationState.AddAnimation(0, "run", true, 0); // Queue walk to be looped on track 0 after the jump animation.
 		}
 	}