1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace Spine.Unity.Examples {
- public class SpineboyFreeze : MonoBehaviour {
- public SkeletonAnimation skeletonAnimation;
- public AnimationReferenceAsset freeze;
- public AnimationReferenceAsset 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;
- }
- }
- }
- }
|