Selaa lähdekoodia

[unity] Fix and update examples.

pharan 8 vuotta sitten
vanhempi
commit
635ef9ca97

+ 3 - 0
spine-unity/Assets/Examples/Other Examples/Mix and Match.unity

@@ -592,6 +592,7 @@ SpriteRenderer:
   m_Size: {x: 1, y: 1}
   m_AdaptiveModeThreshold: 0.5
   m_SpriteTileMode: 0
+  m_WasSpriteAssigned: 1
 --- !u!1 &1262477660
 GameObject:
   m_ObjectHideFlags: 0
@@ -1075,6 +1076,7 @@ Material:
   m_ShaderKeywords: 
   m_LightmapFlags: 5
   m_EnableInstancingVariants: 0
+  m_DoubleSidedGI: 0
   m_CustomRenderQueue: -1
   stringTagMap: {}
   disabledShaderPasses: []
@@ -1296,3 +1298,4 @@ SpriteRenderer:
   m_Size: {x: 1, y: 1}
   m_AdaptiveModeThreshold: 0.5
   m_SpriteTileMode: 0
+  m_WasSpriteAssigned: 1

+ 31 - 0
spine-unity/Assets/Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs

@@ -0,0 +1,31 @@
+using UnityEngine;
+
+namespace Spine.Unity.Examples {
+	public class SpineboyTargetController : MonoBehaviour {
+
+		public SkeletonAnimation skeletonAnimation;
+
+		[SpineBone(dataField:"skeletonAnimation")]
+		public string boneName;
+		public new Camera camera;
+
+		Bone bone;
+
+		void OnValidate () {
+			if (skeletonAnimation == null) skeletonAnimation = GetComponent<SkeletonAnimation>();
+		}
+
+		void Start () {
+			bone = skeletonAnimation.Skeleton.FindBone(boneName);
+		}
+
+		void Update () {
+			var mousePosition = Input.mousePosition;
+			var worldMousePosition = camera.ScreenToWorldPoint(mousePosition);
+			var skeletonSpacePoint = skeletonAnimation.transform.InverseTransformPoint(worldMousePosition);
+			if (skeletonAnimation.Skeleton.FlipX) skeletonSpacePoint.x *= -1;
+			bone.SetPosition(skeletonSpacePoint);
+		}
+	}
+
+}

+ 12 - 0
spine-unity/Assets/Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: af275876c7b01264b85161629a9bc217
+timeCreated: 1489915484
+licenseType: Free
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

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

@@ -30,6 +30,7 @@
 
 using UnityEngine;
 using Spine.Unity.Modules.AttachmentTools;
+using System.Collections;
 
 namespace Spine.Unity.Examples {
 
@@ -69,7 +70,8 @@ namespace Spine.Unity.Examples {
 			}
 		}
 
-		void Start () {
+		IEnumerator Start () {
+			yield return new WaitForSeconds(1f); // Delay for one second before applying. For testing.
 			Apply();
 		}
 

+ 7 - 4
spine-unity/Assets/Examples/Scripts/MixAndMatchGraphic.cs

@@ -30,6 +30,7 @@
 
 using UnityEngine;
 using Spine.Unity.Modules.AttachmentTools;
+using System.Collections;
 
 namespace Spine.Unity.Examples {
 
@@ -69,10 +70,12 @@ namespace Spine.Unity.Examples {
 			}
 		}
 
-		void Start () {
+		IEnumerator Start () {
+			yield return new WaitForSeconds(1f); // Delay for 1 second. For testing.
 			Apply();
 		}
 
+		[ContextMenu("Apply")]
 		void Apply () {
 			var skeletonGraphic = GetComponent<SkeletonGraphic>();
 			var skeleton = skeletonGraphic.Skeleton;
@@ -81,7 +84,7 @@ namespace Spine.Unity.Examples {
 			// Let's prepare a new skin to be our custom skin with equips/customizations. We get a clone so our original skins are unaffected.
 			customSkin = customSkin ?? new Skin("custom skin"); // This requires that all customizations are done with skin placeholders defined in Spine.
 			//customSkin = customSkin ?? skeleton.UnshareSkin(true, false, skeletonAnimation.AnimationState); // use this if you are not customizing on the default skin and don't plan to remove 
-			// Next let's 
+			// Next let's get the skin that contains our source attachments. These are the attachments that 
 			var baseSkin = skeleton.Data.FindSkin(baseSkinName);
 
 			// STEP 1: "EQUIP" ITEMS USING SPRITES
@@ -113,7 +116,6 @@ namespace Spine.Unity.Examples {
 			// 				Repacking requires that you set all source textures/sprites/atlases to be Read/Write enabled in the inspector.
 			// 				Combine all the attachment sources into one skin. Usually this means the default skin and the custom skin.
 			// 				call Skin.GetRepackedSkin to get a cloned skin with cloned attachments that all use one texture.
-			//				Under the hood, this relies on 
 			if (repack)	{
 				var repackedSkin = new Skin("repacked skin");
 				repackedSkin.Append(skeleton.Data.DefaultSkin);
@@ -124,7 +126,8 @@ namespace Spine.Unity.Examples {
 				skeleton.SetSkin(customSkin);
 			}
 
-			skeleton.SetSlotsToSetupPose();
+			//skeleton.SetSlotsToSetupPose();
+			skeleton.SetToSetupPose();
 			skeletonGraphic.Update(0);
 			skeletonGraphic.OverrideTexture = runtimeAtlas;
 

+ 2 - 1
spine-unity/Assets/Examples/Spine/Raptor/raptor_SkeletonData.asset

@@ -13,8 +13,9 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   atlasAssets:
   - {fileID: 11400000, guid: d5fc231712b346f459c8583fa224a669, type: 2}
-  skeletonJSON: {fileID: 4900000, guid: 3ae635b4540c450408d30a8afb9f75a7, type: 3}
+  spriteCollection: {fileID: 0}
   scale: 0.01
+  skeletonJSON: {fileID: 4900000, guid: 3ae635b4540c450408d30a8afb9f75a7, type: 3}
   fromAnimation: []
   toAnimation: []
   duration: []

+ 2 - 0
spine-unity/Assets/Examples/Spine/spineboy-unity/spineboy_Material.mat

@@ -11,6 +11,7 @@ Material:
   m_ShaderKeywords: 
   m_LightmapFlags: 5
   m_EnableInstancingVariants: 0
+  m_DoubleSidedGI: 0
   m_CustomRenderQueue: -1
   stringTagMap: {}
   disabledShaderPasses: []
@@ -29,5 +30,6 @@ Material:
     - _RefractionStrength: 0.01
     - _node_3476: 0
     m_Colors:
+    - _Black: {r: 0, g: 0, b: 0, a: 0}
     - _Color: {r: 1, g: 1, b: 1, a: 1}
     - _FillColor: {r: 1, g: 1, b: 1, a: 1}