From 635ef9ca9737066cd61c8a092118f9ab206d20c8 Mon Sep 17 00:00:00 2001 From: pharan Date: Mon, 26 Jun 2017 15:34:55 +0800 Subject: [PATCH] [unity] Fix and update examples. --- .../Other Examples/Mix and Match.unity | 3 ++ .../SpineboyTargetController.cs | 31 +++++++++++++++++++ .../SpineboyTargetController.cs.meta | 12 +++++++ .../Assets/Examples/Scripts/MixAndMatch.cs | 4 ++- .../Examples/Scripts/MixAndMatchGraphic.cs | 11 ++++--- .../Spine/Raptor/raptor_SkeletonData.asset | 3 +- .../spineboy-unity/spineboy_Material.mat | 2 ++ 7 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 spine-unity/Assets/Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs create mode 100644 spine-unity/Assets/Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs.meta diff --git a/spine-unity/Assets/Examples/Other Examples/Mix and Match.unity b/spine-unity/Assets/Examples/Other Examples/Mix and Match.unity index 8300345af..5f9aa6cc5 100644 --- a/spine-unity/Assets/Examples/Other Examples/Mix and Match.unity +++ b/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 diff --git a/spine-unity/Assets/Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs b/spine-unity/Assets/Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs new file mode 100644 index 000000000..63242c16f --- /dev/null +++ b/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(); + } + + 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); + } + } + +} diff --git a/spine-unity/Assets/Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs.meta b/spine-unity/Assets/Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs.meta new file mode 100644 index 000000000..5275927c3 --- /dev/null +++ b/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: diff --git a/spine-unity/Assets/Examples/Scripts/MixAndMatch.cs b/spine-unity/Assets/Examples/Scripts/MixAndMatch.cs index 5c161dc3d..e48427cd2 100644 --- a/spine-unity/Assets/Examples/Scripts/MixAndMatch.cs +++ b/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(); } diff --git a/spine-unity/Assets/Examples/Scripts/MixAndMatchGraphic.cs b/spine-unity/Assets/Examples/Scripts/MixAndMatchGraphic.cs index 530880421..928000e4f 100644 --- a/spine-unity/Assets/Examples/Scripts/MixAndMatchGraphic.cs +++ b/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(); 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; diff --git a/spine-unity/Assets/Examples/Spine/Raptor/raptor_SkeletonData.asset b/spine-unity/Assets/Examples/Spine/Raptor/raptor_SkeletonData.asset index 3e9abdbb5..b88d2bb1c 100644 --- a/spine-unity/Assets/Examples/Spine/Raptor/raptor_SkeletonData.asset +++ b/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: [] diff --git a/spine-unity/Assets/Examples/Spine/spineboy-unity/spineboy_Material.mat b/spine-unity/Assets/Examples/Spine/spineboy-unity/spineboy_Material.mat index c1cda9ded..664a11c50 100644 --- a/spine-unity/Assets/Examples/Spine/spineboy-unity/spineboy_Material.mat +++ b/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}