From 1517ffcde43fd448fec38e59f5c2f97d9971be24 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Wed, 10 Nov 2021 11:03:23 +0100 Subject: [PATCH] [unity] Renamed example script `DataAssetsFromExportsExample` to `RuntimeLoadFromExportsExample` and performed minor cleanup. --- ...le.cs => RuntimeLoadFromExportsExample.cs} | 24 +++++++++++-------- ... => RuntimeLoadFromExportsExample.cs.meta} | 0 2 files changed, 14 insertions(+), 10 deletions(-) rename spine-unity/Assets/Spine Examples/Scripts/{DataAssetsFromExportsExample.cs => RuntimeLoadFromExportsExample.cs} (85%) rename spine-unity/Assets/Spine Examples/Scripts/{DataAssetsFromExportsExample.cs.meta => RuntimeLoadFromExportsExample.cs.meta} (100%) diff --git a/spine-unity/Assets/Spine Examples/Scripts/DataAssetsFromExportsExample.cs b/spine-unity/Assets/Spine Examples/Scripts/RuntimeLoadFromExportsExample.cs similarity index 85% rename from spine-unity/Assets/Spine Examples/Scripts/DataAssetsFromExportsExample.cs rename to spine-unity/Assets/Spine Examples/Scripts/RuntimeLoadFromExportsExample.cs index f5bf4f9f5..39339ae55 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/DataAssetsFromExportsExample.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/RuntimeLoadFromExportsExample.cs @@ -32,13 +32,17 @@ using System.Collections.Generic; using UnityEngine; namespace Spine.Unity.Examples { - public class DataAssetsFromExportsExample : MonoBehaviour { + public class RuntimeLoadFromExportsExample : MonoBehaviour { public TextAsset skeletonJson; public TextAsset atlasText; public Texture2D[] textures; public Material materialPropertySource; + public float delay = 0; + public string skinName; + public string animationName; + SpineAtlasAsset runtimeAtlasAsset; SkeletonDataAsset runtimeSkeletonDataAsset; SkeletonAnimation runtimeSkeletonAnimation; @@ -54,19 +58,19 @@ namespace Spine.Unity.Examples { IEnumerator Start () { CreateRuntimeAssetsAndGameObject(); - runtimeSkeletonDataAsset.GetSkeletonData(false); // preload. - yield return new WaitForSeconds(0.5f); - + if (delay > 0) { + runtimeSkeletonDataAsset.GetSkeletonData(false); // preload + yield return new WaitForSeconds(delay); + } runtimeSkeletonAnimation = SkeletonAnimation.NewSkeletonAnimationGameObject(runtimeSkeletonDataAsset); - // Extra Stuff + // additional initialization runtimeSkeletonAnimation.Initialize(false); - runtimeSkeletonAnimation.Skeleton.SetSkin("base"); + if (skinName != "") + runtimeSkeletonAnimation.Skeleton.SetSkin(skinName); runtimeSkeletonAnimation.Skeleton.SetSlotsToSetupPose(); - runtimeSkeletonAnimation.AnimationState.SetAnimation(0, "run", true); - runtimeSkeletonAnimation.GetComponent().sortingOrder = 10; - runtimeSkeletonAnimation.transform.Translate(Vector3.down * 2); - + if (animationName != "") + runtimeSkeletonAnimation.AnimationState.SetAnimation(0, animationName, true); } } diff --git a/spine-unity/Assets/Spine Examples/Scripts/DataAssetsFromExportsExample.cs.meta b/spine-unity/Assets/Spine Examples/Scripts/RuntimeLoadFromExportsExample.cs.meta similarity index 100% rename from spine-unity/Assets/Spine Examples/Scripts/DataAssetsFromExportsExample.cs.meta rename to spine-unity/Assets/Spine Examples/Scripts/RuntimeLoadFromExportsExample.cs.meta