예제 #1
0
        public ImportedAnimationSheet Import(AnimationImportJob job, AnimationImporterSharedConfig config)
        {
            if (ImportImageAndMetaInfo(job))
            {
                AssetDatabase.Refresh();
                return(GetAnimationInfo(_latestData));
            }

            return(null);
        }
예제 #2
0
        // ================================================================================
        //  public methods
        // --------------------------------------------------------------------------------

        public ImportedAnimationSheet Import(AnimationImportJob job, AnimationImporterSharedConfig config)
        {
            if (CreateSpriteAtlasAndMetaFile(job))
            {
                AssetDatabase.Refresh();

                ImportedAnimationSheet animationSheet = CreateAnimationSheetFromMetaData(job, config);

                return(animationSheet);
            }

            return(null);
        }
예제 #3
0
        // ================================================================================
        //  public methods
        // --------------------------------------------------------------------------------

        public ImportedAnimationSheet Import(AnimationImportJob job, AnimationImporterSharedConfig config)
        {
            Texture2D  srcTex;
            JSONObject metaData;

            if (CreateSpriteAtlasAndMetaFile(job, out srcTex, out metaData))
            {
                ImportedAnimationSheet animationSheet = CreateAnimationSheetFromMetaData(job, config, srcTex, metaData);

                return(animationSheet);
            }

            return(null);
        }
예제 #4
0
        // ================================================================================
        //  private methods
        // --------------------------------------------------------------------------------

        // parses a JSON file and creates the raw data for ImportedAnimationSheet from it
        private static ImportedAnimationSheet CreateAnimationSheetFromMetaData(AnimationImportJob job, AnimationImporterSharedConfig config)
        {
            string    textAssetFilename = job.directoryPathForSprites + "/" + job.name + ".json";
            TextAsset textAsset         = AssetDatabase.LoadAssetAtPath <TextAsset>(textAssetFilename);

            if (textAsset != null)
            {
                JSONObject             jsonObject     = JSONObject.Parse(textAsset.ToString());
                ImportedAnimationSheet animationSheet = GetAnimationInfo(jsonObject);

                if (animationSheet == null)
                {
                    return(null);
                }

                animationSheet.previousImportSettings = job.previousImportSettings;

                animationSheet.SetNonLoopingAnimations(config.animationNamesThatDoNotLoop);

                // delete JSON file afterwards
                AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(textAsset));

                return(animationSheet);
            }
            else
            {
                Debug.LogWarning("Problem with JSON file: " + textAssetFilename);
            }

            return(null);
        }
예제 #5
0
        // ================================================================================
        //  private methods
        // --------------------------------------------------------------------------------

        // parses a JSON file and creates the raw data for ImportedAnimationSheet from it
        private static ImportedAnimationSheet CreateAnimationSheetFromMetaData(AnimationImportJob job, AnimationImporterSharedConfig config, Texture2D srcTex, JSONObject metadata)
        {
            job.SetProgress(0.2f, "getting animation sheet...");
            if (metadata != null && srcTex != null)
            {
                ImportedAnimationSheet animationSheet = GetAnimationInfo(metadata);

                if (animationSheet == null)
                {
                    return(null);
                }
                animationSheet.srcTex = srcTex;

                if (!animationSheet.hasAnimations)
                {
                    Debug.LogWarning("No Animations found in Aseprite file. Use Aseprite Tags to assign names to Animations.");
                }

                animationSheet.SetNonLoopingAnimations(config.animationNamesThatDoNotLoop);

                return(animationSheet);
            }

            return(null);
        }