mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[unity] Renamed example script DataAssetsFromExportsExample to RuntimeLoadFromExportsExample and performed minor cleanup.
This commit is contained in:
parent
618e20dc9a
commit
1517ffcde4
@ -32,13 +32,17 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Spine.Unity.Examples {
|
namespace Spine.Unity.Examples {
|
||||||
public class DataAssetsFromExportsExample : MonoBehaviour {
|
public class RuntimeLoadFromExportsExample : MonoBehaviour {
|
||||||
|
|
||||||
public TextAsset skeletonJson;
|
public TextAsset skeletonJson;
|
||||||
public TextAsset atlasText;
|
public TextAsset atlasText;
|
||||||
public Texture2D[] textures;
|
public Texture2D[] textures;
|
||||||
public Material materialPropertySource;
|
public Material materialPropertySource;
|
||||||
|
|
||||||
|
public float delay = 0;
|
||||||
|
public string skinName;
|
||||||
|
public string animationName;
|
||||||
|
|
||||||
SpineAtlasAsset runtimeAtlasAsset;
|
SpineAtlasAsset runtimeAtlasAsset;
|
||||||
SkeletonDataAsset runtimeSkeletonDataAsset;
|
SkeletonDataAsset runtimeSkeletonDataAsset;
|
||||||
SkeletonAnimation runtimeSkeletonAnimation;
|
SkeletonAnimation runtimeSkeletonAnimation;
|
||||||
@ -54,19 +58,19 @@ namespace Spine.Unity.Examples {
|
|||||||
|
|
||||||
IEnumerator Start () {
|
IEnumerator Start () {
|
||||||
CreateRuntimeAssetsAndGameObject();
|
CreateRuntimeAssetsAndGameObject();
|
||||||
runtimeSkeletonDataAsset.GetSkeletonData(false); // preload.
|
if (delay > 0) {
|
||||||
yield return new WaitForSeconds(0.5f);
|
runtimeSkeletonDataAsset.GetSkeletonData(false); // preload
|
||||||
|
yield return new WaitForSeconds(delay);
|
||||||
|
}
|
||||||
runtimeSkeletonAnimation = SkeletonAnimation.NewSkeletonAnimationGameObject(runtimeSkeletonDataAsset);
|
runtimeSkeletonAnimation = SkeletonAnimation.NewSkeletonAnimationGameObject(runtimeSkeletonDataAsset);
|
||||||
|
|
||||||
// Extra Stuff
|
// additional initialization
|
||||||
runtimeSkeletonAnimation.Initialize(false);
|
runtimeSkeletonAnimation.Initialize(false);
|
||||||
runtimeSkeletonAnimation.Skeleton.SetSkin("base");
|
if (skinName != "")
|
||||||
|
runtimeSkeletonAnimation.Skeleton.SetSkin(skinName);
|
||||||
runtimeSkeletonAnimation.Skeleton.SetSlotsToSetupPose();
|
runtimeSkeletonAnimation.Skeleton.SetSlotsToSetupPose();
|
||||||
runtimeSkeletonAnimation.AnimationState.SetAnimation(0, "run", true);
|
if (animationName != "")
|
||||||
runtimeSkeletonAnimation.GetComponent<MeshRenderer>().sortingOrder = 10;
|
runtimeSkeletonAnimation.AnimationState.SetAnimation(0, animationName, true);
|
||||||
runtimeSkeletonAnimation.transform.Translate(Vector3.down * 2);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user