Ejemplo n.º 1
0
        private Level[] GetExternalLevels(Level[] projectLevels)
        {
            List <Level>             levels       = new List <Level>();
            LDtkRelativeGetterLevels finderLevels = new LDtkRelativeGetterLevels();

            string[] levelFiles = projectLevels.Select(lvl => finderLevels.ReadRelativeText(lvl, _importer.ImportContext.assetPath)).ToArray();
            //todo test what might happen when we try broken file paths

            foreach (string json in levelFiles)
            {
                if (json == null)
                {
                    Debug.LogError("LDtk: Level file was null, ignored. May cause problems?", _importer);
                    continue;
                }

                Level level = Level.FromJson(json);
                Assert.IsNotNull(level);

                levels.Add(level);

                //add dependency so that we trigger a reimport if we reimport a level due to it being saved
                //_importer.SetupAssetDependency(json); //todo verify if we need to disable a dependency here if they are external levels.
            }
            return(levels.ToArray());
        }
Ejemplo n.º 2
0
        private Level[] GetExternalLevels(Level[] projectLevels)
        {
            List <Level> levels = new List <Level>();

            LDtkRelativeGetterLevels finderLevels = new LDtkRelativeGetterLevels();

            LDtkLevelFile[] levelFiles = projectLevels.Select(lvl => finderLevels.GetRelativeAsset(lvl, _importer.ImportContext.assetPath)).ToArray();

            foreach (LDtkLevelFile file in levelFiles)
            {
                if (file == null)
                {
                    Debug.LogError("LDtk: Level file was null, ignored. May cause problems?", _importer);
                    continue;
                }

                Level level = file.FromJson;
                Assert.IsNotNull(level);

                levels.Add(level);

                //add dependency so that we trigger a reimport if we reimport a level due to it being saved
                string levelFilePath = AssetDatabase.GetAssetPath(file);
                _importer.ImportContext.DependsOnSourceAsset(levelFilePath);
            }
            return(levels.ToArray());
        }