void binderHandler(SpriteAnimation ani) { foreach (BinderItem item in bindObjects) { SpriteTransform tmp = spriteRenderer.GetSpriteTransform(item.componentName); if (tmp != null) { Vector3 offset = item.offset; Vector3 position = tmp.position; Vector3 pos = position + (Quaternion.Euler(0, 0, tmp.rotation) * offset); pos.z = item.bindObject.transform.position.z; item.bindObject.transform.position = transform.TransformPoint(pos); item.bindObject.transform.rotation = Quaternion.Euler(0, 0, transform.eulerAngles.z + tmp.rotation + item.rotation); } } }
public override void OnEnter() { self = Fsm.GetOwnerDefaultTarget(selfObject); // Get the target of the animation TargetGameObject = Fsm.GetOwnerDefaultTarget(gameObject); // If there is no target if (TargetGameObject == null && AnimationName != null) { Finish(); return; } spriteAnimation = TargetGameObject.GetComponent<SpriteAnimation>(); spriteRender = TargetGameObject.GetComponent<SpriteRenderer>(); if (color.Value != Color.white) { spriteRender.color = color.Value; } spriteRender.enabled = true; spriteAnimation.StopAll(); string fileName; string name = TargetGameObject.name; Debug.Log(name); fileName = "EMAnim_" + name + "_" + AnimationName.Value; int currentPhase = phase.Value; if (currentPhase !=0) { fileName += "_p" + currentPhase; } spriteRender.enabled = true; spriteAnimation.StopAll(); spriteAnimation.Play(fileName); spriteAnimation.UpdateInternal(0f); spriteAnimation.CalculateData(); spriteAnimation.gameObject.GetComponent<SpriteMeshRenderer>().Update(); }
/// <summary> /// Sets the array of SpriteAnimationClips to be referenced in the Animation component /// </summary> public static void SetAnimationClips(SpriteAnimation animation, SpriteAnimationClip[] clips) { animation.SetClips(clips); }
/// <summary> /// Returns the array of SpriteAnimationClips that are referenced in the Animation component /// </summary> public static SpriteAnimationClip[] GetAnimationClips(SpriteAnimation animation) { return animation.GetClips(); }
void Update() { if (!Application.isPlaying) { // Since this can be run in editor mode, we could come across a situation where the spriteRenderer has not // yet been assigned. Make sure we can assign it here before continuing. if (spriteRenderer == null) spriteRenderer = GetComponent<SpriteRenderer>(); else { if (GetComponent<SpriteRenderer>() == null) { spriteRenderer = null; RemoveAllCollider(); } } if (spriteAnimation == null) { spriteAnimation = GetComponent<SpriteAnimation>(); if (spriteAnimation != null) { BuildCollider(); } } else { if (GetComponent<SpriteAnimation>() == null) { spriteAnimation = null; RemoveAllCollider(); } } } }
// Use this for initialization void OnEnable() { spriteRenderer = GetComponent<SpriteRenderer>(); spriteAnimation = GetComponent<SpriteAnimation>(); ChangeType(type, type); }
void applyBounding(SpriteAnimation ani) { foreach (ColliderNode node in colliderNones) { if (node.colliderObject != null) { updateCollisionTransformsForNode(node); } } }
static void dummyHandler(SpriteAnimation ani) { }
/// <summary> /// Returns the array of SpriteAnimationClips that are referenced in the Animation component /// </summary> public static SpriteAnimationClip[] GetAnimationClips(SpriteAnimation animation) { return(animation.GetClips()); }
private SpriteAnimationState(SpriteAnimationClip clip, SpriteAnimation animation, string name) { Init(clip, animation, name); }