private static void CreateChildren(SpriterEntity entity, SpriterDotNetBehaviour sdnBehaviour, Spriter spriter, GameObject parent) { int maxObjects = 0; foreach (SpriterAnimation animation in entity.Animations) { foreach (SpriterMainLineKey mainKey in animation.MainlineKeys) { maxObjects = Math.Max(maxObjects, mainKey.ObjectRefs.Length); } } sdnBehaviour.Children = new GameObject[maxObjects]; sdnBehaviour.Pivots = new GameObject[maxObjects]; for (int i = 0; i < maxObjects; ++i) { GameObject pivot = new GameObject(); GameObject child = new GameObject(); sdnBehaviour.Pivots[i] = pivot; sdnBehaviour.Children[i] = child; pivot.transform.SetParent(parent.transform); child.transform.SetParent(pivot.transform); child.transform.localPosition = new Vector3(0, 0, DeltaZ * i); pivot.name = "pivot " + i; child.name = "child " + i; child.AddComponent<SpriteRenderer>(); } }
/// <summary> /// Sole constructor. Creates a new instance which animates the given entity. /// </summary> protected SpriterAnimator(SpriterEntity entity) { Entity = entity; animations = entity.Animations.ToDictionary(a => a.Name, a => a); Speed = 1.0f; Metadata = new FrameMetadata(); DataProvider = new DefaultAnimationDataProvider(); }
public SpriterAnimator(SpriterEntity entity) { Entity = entity; Spriter = entity.Spriter; animations = entity.Animations.ToDictionary(a => a.Name, a => a); Speed = 1.0f; Play(animations.Keys.First()); Metadata = new FrameMetadata(); }
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 }
protected Animator(SpriterEntity entity, IProviderFactory <TSprite, TSound> providerFactory = null) { Entity = entity; Animations = entity.Animations.ToDictionary(a => a.Name, a => a); Speed = 1.0f; if (providerFactory != null) { DataProvider = providerFactory.GetDataProvider(entity); SpriteProvider = providerFactory.GetSpriteProvider(entity); SoundProvider = providerFactory.GetSoundProvider(entity); } else { DataProvider = new DefaultFrameDataProvider(); SpriteProvider = new DefaultAssetProvider <TSprite>(); SoundProvider = new DefaultAssetProvider <TSound>(); } }
private static void SpriterImporter_EntityImported(SpriterEntity entity, GameObject go) { Debug.Log("Imported Entity: " + entity.Name); }