mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[unity] Fix and update examples.
This commit is contained in:
parent
fc06686080
commit
635ef9ca97
@ -592,6 +592,7 @@ SpriteRenderer:
|
|||||||
m_Size: {x: 1, y: 1}
|
m_Size: {x: 1, y: 1}
|
||||||
m_AdaptiveModeThreshold: 0.5
|
m_AdaptiveModeThreshold: 0.5
|
||||||
m_SpriteTileMode: 0
|
m_SpriteTileMode: 0
|
||||||
|
m_WasSpriteAssigned: 1
|
||||||
--- !u!1 &1262477660
|
--- !u!1 &1262477660
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -1075,6 +1076,7 @@ Material:
|
|||||||
m_ShaderKeywords:
|
m_ShaderKeywords:
|
||||||
m_LightmapFlags: 5
|
m_LightmapFlags: 5
|
||||||
m_EnableInstancingVariants: 0
|
m_EnableInstancingVariants: 0
|
||||||
|
m_DoubleSidedGI: 0
|
||||||
m_CustomRenderQueue: -1
|
m_CustomRenderQueue: -1
|
||||||
stringTagMap: {}
|
stringTagMap: {}
|
||||||
disabledShaderPasses: []
|
disabledShaderPasses: []
|
||||||
@ -1296,3 +1298,4 @@ SpriteRenderer:
|
|||||||
m_Size: {x: 1, y: 1}
|
m_Size: {x: 1, y: 1}
|
||||||
m_AdaptiveModeThreshold: 0.5
|
m_AdaptiveModeThreshold: 0.5
|
||||||
m_SpriteTileMode: 0
|
m_SpriteTileMode: 0
|
||||||
|
m_WasSpriteAssigned: 1
|
||||||
|
|||||||
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: af275876c7b01264b85161629a9bc217
|
||||||
|
timeCreated: 1489915484
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Spine.Unity.Modules.AttachmentTools;
|
using Spine.Unity.Modules.AttachmentTools;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
namespace Spine.Unity.Examples {
|
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();
|
Apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Spine.Unity.Modules.AttachmentTools;
|
using Spine.Unity.Modules.AttachmentTools;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
namespace Spine.Unity.Examples {
|
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();
|
Apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ContextMenu("Apply")]
|
||||||
void Apply () {
|
void Apply () {
|
||||||
var skeletonGraphic = GetComponent<SkeletonGraphic>();
|
var skeletonGraphic = GetComponent<SkeletonGraphic>();
|
||||||
var skeleton = skeletonGraphic.Skeleton;
|
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.
|
// 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 ?? 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
|
//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);
|
var baseSkin = skeleton.Data.FindSkin(baseSkinName);
|
||||||
|
|
||||||
// STEP 1: "EQUIP" ITEMS USING SPRITES
|
// 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.
|
// 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.
|
// 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.
|
// call Skin.GetRepackedSkin to get a cloned skin with cloned attachments that all use one texture.
|
||||||
// Under the hood, this relies on
|
|
||||||
if (repack) {
|
if (repack) {
|
||||||
var repackedSkin = new Skin("repacked skin");
|
var repackedSkin = new Skin("repacked skin");
|
||||||
repackedSkin.Append(skeleton.Data.DefaultSkin);
|
repackedSkin.Append(skeleton.Data.DefaultSkin);
|
||||||
@ -124,7 +126,8 @@ namespace Spine.Unity.Examples {
|
|||||||
skeleton.SetSkin(customSkin);
|
skeleton.SetSkin(customSkin);
|
||||||
}
|
}
|
||||||
|
|
||||||
skeleton.SetSlotsToSetupPose();
|
//skeleton.SetSlotsToSetupPose();
|
||||||
|
skeleton.SetToSetupPose();
|
||||||
skeletonGraphic.Update(0);
|
skeletonGraphic.Update(0);
|
||||||
skeletonGraphic.OverrideTexture = runtimeAtlas;
|
skeletonGraphic.OverrideTexture = runtimeAtlas;
|
||||||
|
|
||||||
|
|||||||
@ -13,8 +13,9 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
atlasAssets:
|
atlasAssets:
|
||||||
- {fileID: 11400000, guid: d5fc231712b346f459c8583fa224a669, type: 2}
|
- {fileID: 11400000, guid: d5fc231712b346f459c8583fa224a669, type: 2}
|
||||||
skeletonJSON: {fileID: 4900000, guid: 3ae635b4540c450408d30a8afb9f75a7, type: 3}
|
spriteCollection: {fileID: 0}
|
||||||
scale: 0.01
|
scale: 0.01
|
||||||
|
skeletonJSON: {fileID: 4900000, guid: 3ae635b4540c450408d30a8afb9f75a7, type: 3}
|
||||||
fromAnimation: []
|
fromAnimation: []
|
||||||
toAnimation: []
|
toAnimation: []
|
||||||
duration: []
|
duration: []
|
||||||
|
|||||||
@ -11,6 +11,7 @@ Material:
|
|||||||
m_ShaderKeywords:
|
m_ShaderKeywords:
|
||||||
m_LightmapFlags: 5
|
m_LightmapFlags: 5
|
||||||
m_EnableInstancingVariants: 0
|
m_EnableInstancingVariants: 0
|
||||||
|
m_DoubleSidedGI: 0
|
||||||
m_CustomRenderQueue: -1
|
m_CustomRenderQueue: -1
|
||||||
stringTagMap: {}
|
stringTagMap: {}
|
||||||
disabledShaderPasses: []
|
disabledShaderPasses: []
|
||||||
@ -29,5 +30,6 @@ Material:
|
|||||||
- _RefractionStrength: 0.01
|
- _RefractionStrength: 0.01
|
||||||
- _node_3476: 0
|
- _node_3476: 0
|
||||||
m_Colors:
|
m_Colors:
|
||||||
|
- _Black: {r: 0, g: 0, b: 0, a: 0}
|
||||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _FillColor: {r: 1, g: 1, b: 1, a: 1}
|
- _FillColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user