mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 09:46:02 +08:00
65 lines
1.5 KiB
C#
65 lines
1.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Spine.Unity.Examples {
|
|
public class SpineboyFreeze : MonoBehaviour {
|
|
|
|
public SkeletonAnimation skeletonAnimation;
|
|
[SpineAnimation]
|
|
public string freeze;
|
|
[SpineAnimation]
|
|
public string idle;
|
|
|
|
public Color freezeColor;
|
|
public Color freezeBlackColor;
|
|
public ParticleSystem particles;
|
|
public float freezePoint = 0.5f;
|
|
|
|
public string colorProperty = "_Color";
|
|
public string blackTintProperty = "_Black";
|
|
|
|
MaterialPropertyBlock block;
|
|
MeshRenderer meshRenderer;
|
|
|
|
IEnumerator Start () {
|
|
block = new MaterialPropertyBlock();
|
|
meshRenderer = GetComponent<MeshRenderer>();
|
|
|
|
particles.Stop();
|
|
particles.Clear();
|
|
var main = particles.main;
|
|
main.loop = false;
|
|
|
|
var state = skeletonAnimation.AnimationState;
|
|
while (true) {
|
|
|
|
yield return new WaitForSeconds(1f);
|
|
|
|
// Play freeze animation
|
|
state.SetAnimation(0, freeze, false);
|
|
yield return new WaitForSeconds(freezePoint);
|
|
|
|
// Freeze effects
|
|
particles.Play();
|
|
block.SetColor(colorProperty, freezeColor);
|
|
block.SetColor(blackTintProperty, freezeBlackColor);
|
|
meshRenderer.SetPropertyBlock(block);
|
|
|
|
|
|
yield return new WaitForSeconds(2f);
|
|
|
|
// Return to Idle
|
|
state.SetAnimation(0, idle, true);
|
|
block.SetColor(colorProperty, Color.white);
|
|
block.SetColor(blackTintProperty, Color.black);
|
|
meshRenderer.SetPropertyBlock(block);
|
|
|
|
|
|
yield return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|