Esempio n. 1
0
        /// <returns>The atlas or null if it could not be loaded.</returns>
        public override Atlas GetAtlas()
        {
            if (atlasFile == null)
            {
                Debug.LogError("Atlas file not set for atlas asset: " + name, this);
                Clear();
                return(null);
            }

            if (materials == null || materials.Length == 0)
            {
                Debug.LogError("Materials not set for atlas asset: " + name, this);
                Clear();
                return(null);
            }

            if (atlas != null)
            {
                return(atlas);
            }

            try {
                atlas = new Atlas(new StringReader(atlasFile.text), "", new MaterialsTextureLoader(this));
                atlas.FlipV();
                return(atlas);
            } catch (Exception ex) {
                Debug.LogError("Error reading atlas file for atlas asset: " + name + "\n" + ex.Message + "\n" + ex.StackTrace, this);
                return(null);
            }
        }
Esempio n. 2
0
        /// <returns>The atlas or null if it could not be loaded.</returns>
        public override Atlas GetAtlas(bool onlyMetaData = false)
        {
            if (atlasFile == null)
            {
                Debug.LogError("Atlas file not set for atlas asset: " + name, this);
                Clear();
                return(null);
            }

            if (!onlyMetaData && (materials == null || materials.Length == 0))
            {
                Debug.LogError("Materials not set for atlas asset: " + name, this);
                Clear();
                return(null);
            }

            if (atlas != null)
            {
                return(atlas);
            }

            try {
                TextureLoader loader;
                if (!onlyMetaData)
                {
                    loader = new MaterialsTextureLoader(this);
                }
                else
                {
                    loader = new NoOpTextureLoader();
                }
                atlas = new Atlas(new StringReader(atlasFile.text), "", loader);
                atlas.FlipV();
                return(atlas);
            } catch (Exception ex) {
                Debug.LogError("Error reading atlas file for atlas asset: " + name + "\n" + ex.Message + "\n" + ex.StackTrace, this);
                return(null);
            }
        }
Esempio n. 3
0
    public SkeletonData GetSkeletonData(bool quiet)
    {
        if (atlasAsset == null)
        {
            if (!quiet)
            {
                Debug.LogError("Atlas not set for SkeletonData asset: " + name, this);
            }
            Clear();
            return(null);
        }

        if (skeletonJSON == null)
        {
            if (!quiet)
            {
                Debug.LogError("Skeleton JSON file not set for SkeletonData asset: " + name, this);
            }
            Clear();
            return(null);
        }

        Atlas atlas = atlasAsset.GetAtlas();

        if (atlas == null)
        {
            Clear();
            return(null);
        }

        if (skeletonData != null)
        {
            return(skeletonData);
        }

        atlas.FlipV();
        SkeletonJson json = new SkeletonJson(atlas);

        json.Scale = scale;
        try {
            skeletonData = json.ReadSkeletonData(new StringReader(skeletonJSON.text));
        } catch (Exception ex) {
            if (!quiet)
            {
                Debug.LogError("Error reading skeleton JSON file for SkeletonData asset: " + name + "\n" + ex.Message + "\n" + ex.StackTrace, this);
            }
            return(null);
        }

        stateData = new AnimationStateData(skeletonData);
        for (int i = 0, n = fromAnimation.Length; i < n; i++)
        {
            if (fromAnimation[i].Length == 0 || toAnimation[i].Length == 0)
            {
                continue;
            }
            stateData.SetMix(fromAnimation[i], toAnimation[i], duration[i]);
        }

        return(skeletonData);
    }