public void Setup(ZT_Sprite newZtSprite, ZTTimeManager.ZTTime timeCon, ZT_SpriteAnimator newAnimator) { sp = newZtSprite; timeObject = timeCon; ztAnimator = newAnimator; originalSpeed = speed; //run through each frame group and decide if we can show 8 directions or just 4 int extraAngles = 0; foreach (DirectionGroup frameGroup in frameGroups) { switch (frameGroup.direction) { case (FaceDirection.Direction.LowerLeft): extraAngles++; break; case (FaceDirection.Direction.LowerRight): extraAngles++; break; case (FaceDirection.Direction.UpperLeft): extraAngles++; break; case (FaceDirection.Direction.UpperRight): extraAngles++; break; } } if (extraAngles == 4) { use8wayDir = true; } else { use8wayDir = false; } }
public void Initialize() { if (addToMasterList) { ZT_SpriteMaster.AddSpriteAnim(this); } //Set Sprite Component if (useUnityUiImage && uiImage == null) { uiImage = GetComponent <Image>(); } else if (sp == null) { sp = GetComponent <ZT_Sprite>(); } //if no animations are on this object try to load from resources if (loadAnimations == null || loadAnimations.Length == 0) { loadAnimations = Resources.LoadAll <ZT_SpriteAnimation>(ResourcesDir); } if (loadAnimations == null) { return; } //load each animation. We use the loadAnimations array so we can set in the inspector foreach (ZT_SpriteAnimation anim in loadAnimations) { LoadAnimation(anim); } //release loadanimations array from memory System.Array.Clear(loadAnimations, 0, loadAnimations.Length); loadAnimations = null; initialized = true; }