Esempio n. 1
0
        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;
        }