// Update is called once per frame void Update() { if (animator == null) { animator = GetComponent<SpriterDotNetBehaviour>().Animator; animator.Play("an_climb"); //animator.Transition("an_fly", 2f); } animator.AnimationFinished += animationFinished; }
public void Start() { animator = new UnitySpriterAnimator(Entity, Pivots, Children); RegisterSprites(); #if UNITY_EDITOR if (!UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode) animator.Step(Time.deltaTime); #endif }
public void Start() { SpriterEntity entity = SpriterData.Spriter.Entities[EntityIndex]; AudioSource audioSource = gameObject.GetComponent<AudioSource>(); Animator = new UnitySpriterAnimator(entity, ChildData, audioSource); RegisterSpritesAndSounds(); if (UseNativeTags) defaultTag = gameObject.tag; Animator.Step(0); }
public void Awake() { #if UNITY_EDITOR if(deserializationComplete){ Spriter spriter = Spriter.Parse(SpriterData); entity = spriter.Entities[0]; animator = new UnitySpriterAnimator(entity, Pivots, Children); RegisterSprites(); if (!UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode) animator.Step(Time.deltaTime); } #endif }
public override void Start() { base.Start(); animator = behaviour.Animator; /* display all animations * foreach (var i in animator.GetAnimations()) { * Debug.Log(i); * } */ }
private IEnumerator Start() { do { SpriterAnimator = GetComponent <SpriterDotNetBehaviour> ().Animator; if (SpriterAnimator != null) { break; } yield return(null); } while (true); foreach (var animation in SpriterAnimator.GetAnimations()) { Animations.Add(Animator.StringToHash(animation), animation); } }
private static string GetAnimation(UnitySpriterAnimator animator, int offset) { List <string> animations = animator.GetAnimations().ToList(); int index = animations.IndexOf(animator.CurrentAnimation.Name); index += offset; if (index >= animations.Count) { index = 0; } if (index < 0) { index = animations.Count - 1; } return(animations[index]); }
void Update() { if (animator == null) { animator = FindObjectOfType <SpriterDotNetBehaviour>().Animator; animator.EventTriggered += e => Debug.Log("Event Triggered. Source: " + animator.CurrentAnimation.Name + ". Value: " + e); } if (GetAxisDownPositive("Vertical")) { PushCharacterMap(); } if (GetAxisDownNegative("Vertical")) { animator.PopCharMap(); } if (Input.GetButtonDown("Jump")) { ReverseAnimation(); } if (GetAxisDownPositive("Horizontal")) { Transition(1); } if (GetAxisDownNegative("Horizontal")) { Transition(-1); } if (Input.GetButtonDown("Fire1")) { SwitchAnimation(1); } if (Input.GetButtonDown("Fire2")) { SwitchAnimation(-1); } if (Input.GetButtonDown("Cancel")) { PushCharacterMap(); } float speed = Math.Sign(Input.GetAxis("Mouse ScrollWheel")) * DeltaSpeed; ChangeAnimationSpeed(speed); animator.Speed = AnimatorSpeed; }
void Update() { if (animator == null) { animator = FindObjectOfType<SpriterDotNetBehaviour>().Animator; animator.EventTriggered += e => Debug.Log("Event Triggered. Source: " + animator.CurrentAnimation.Name + ". Value: " + e); } if (GetAxisDownPositive("Vertical")) ChangeAnimationSpeed(DeltaSpeed); if (GetAxisDownNegative("Vertical")) ChangeAnimationSpeed(-DeltaSpeed); if (Input.GetButtonDown("Jump")) ReverseAnimation(); if (GetAxisDownPositive("Horizontal")) Transition(1); if (GetAxisDownNegative("Horizontal")) Transition(-1); if (Input.GetButtonDown("Fire1")) SwitchAnimation(1); if (Input.GetButtonDown("Fire2")) SwitchAnimation(-1); if (Input.GetButtonDown("Cancel")) NextCharacterMap(); animator.Speed = AnimatorSpeed; }
private static string GetAnimation(UnitySpriterAnimator animator, int offset) { List<string> animations = animator.GetAnimations().ToList(); int index = animations.IndexOf(animator.CurrentAnimation.Name); index += offset; if (index >= animations.Count) index = 0; if (index < 0) index = animations.Count - 1; return animations[index]; }
/// Initialize the animatior private void InitAnimator() { SpriterEntity entity = SpriterData.Spriter.Entities[EntityIndex]; AudioSource audioSource = gameObject.GetComponent<AudioSource>(); SpriterAnimator = new UnitySpriterAnimator(entity, ChildData, audioSource); RegisterSpritesAndSounds(); if (UseNativeTags) defaultTag = gameObject.tag; if (!String.IsNullOrEmpty(DefaultAnimation)) { N.Console.Log("Trying to set animation {0}", DefaultAnimation); foreach (var i in SpriterAnimator.GetAnimations()) { N.Console.Log(i); } SpriterAnimator.Transition(DefaultAnimation, 0); } SpriterAnimator.Step(0); }