예제 #1
0
        public override bool Export(ProjectAssetContainer container, string dirPath)
        {
            string folderPath   = Path.Combine(dirPath, Object.AssetsKeyWord, OcclusionCullingSettings.SceneKeyWord);
            string sceneSubPath = GetSceneName(container);
            string fileName     = $"{sceneSubPath}.unity";
            string filePath     = Path.Combine(folderPath, fileName);

            folderPath = Path.GetDirectoryName(filePath);

            if (!DirectoryUtils.Exists(folderPath))
            {
                DirectoryUtils.CreateVirtualDirectory(folderPath);
            }

            AssetExporter.Export(container, Components, filePath);
            SceneImporter sceneImporter = new SceneImporter();
            Meta          meta          = new Meta(sceneImporter, GUID);

            ExportMeta(container, meta, filePath);

            string sceneName     = Path.GetFileName(sceneSubPath);
            string subFolderPath = Path.Combine(folderPath, sceneName);

            if (OcclusionCullingData != null)
            {
                OcclusionCullingData.Initialize(container, m_occlusionCullingSettings);
                ExportAsset(container, OcclusionCullingData, subFolderPath);
            }

            return(true);
        }
        public override bool Export(ProjectAssetContainer container, string dirPath)
        {
            string subFolder = Asset.ExportName;
            string subPath   = Path.Combine(dirPath, subFolder);
            string fileName  = GetUniqueFileName(container.File, Asset, subPath);
            string filePath  = Path.Combine(subPath, fileName);

            string resourcePath;

            if (container.GetResourcePathFromAssets(Assets, filePath, out resourcePath))
            {
                subPath  = Path.GetDirectoryName(resourcePath);
                filePath = resourcePath;
            }

            if (!DirectoryUtils.Exists(subPath))
            {
                DirectoryUtils.CreateVirtualDirectory(subPath);
            }

            if (ExportInner(container, filePath))
            {
                Meta meta = new Meta(MetaImporter, Asset.GUID);
                ExportMeta(container, meta, filePath);
                return(true);
            }
            return(false);
        }
        public override bool Export(ProjectAssetContainer container, string dirPath)
        {
            string subPath  = Path.Combine(dirPath, ProjectSettingsName);
            string fileName = $"{EditorBuildSettings.ClassID.ToString()}.asset";
            string filePath = Path.Combine(subPath, fileName);

            if (!DirectoryUtils.Exists(subPath))
            {
                DirectoryUtils.CreateDirectory(subPath);
            }

            BuildSettings       asset  = (BuildSettings)Asset;
            IEnumerable <Scene> scenes = asset.Scenes.Select(t => new Scene(t, container.SceneNameToGUID(t)));

            EditorBuildSettings.Initialize(scenes);
            AssetExporter.Export(container, EditorBuildSettings, filePath);

            fileName = $"{EditorSettings.ClassID.ToString()}.asset";
            filePath = Path.Combine(subPath, fileName);

            AssetExporter.Export(container, EditorSettings, filePath);

            fileName = $"ProjectVersion.txt";
            filePath = Path.Combine(subPath, fileName);

            using (FileStream file = FileUtils.Create(filePath))
            {
                using (StreamWriter writer = new StreamWriter(file))
                {
                    writer.Write("m_EditorVersion: 2017.3.0f3");
                }
            }
            return(true);
        }
예제 #4
0
        public void Export(string path, FileCollection fileCollection, IEnumerable <Object> assets)
        {
            VirtualSerializedFile    virtualFile = new VirtualSerializedFile();
            List <IExportCollection> collections = new List <IExportCollection>();
            // speed up fetching a little bit
            List <Object>    depList = new List <Object>();
            HashSet <Object> depSet  = new HashSet <Object>();
            HashSet <Object> queued  = new HashSet <Object>();

            depList.AddRange(assets);
            depSet.UnionWith(depList);
            for (int i = 0; i < depList.Count; i++)
            {
                Object asset = depList[i];
                if (!queued.Contains(asset))
                {
                    IExportCollection collection = CreateCollection(virtualFile, asset);
                    foreach (Object element in collection.Assets)
                    {
                        queued.Add(element);
                    }
                    collections.Add(collection);
                }

#warning TODO: if IsGenerateGUIDByContent set it should build collections and write actual references with persistent GUIS, but skip dependencies
                if (Config.IsExportDependencies)
                {
                    foreach (Object dependency in asset.FetchDependencies(true))
                    {
                        if (dependency == null)
                        {
                            continue;
                        }

                        if (!depSet.Contains(dependency))
                        {
                            depList.Add(dependency);
                            depSet.Add(dependency);
                        }
                    }
                }
            }
            depList.Clear();
            depSet.Clear();
            queued.Clear();

            ProjectAssetContainer container = new ProjectAssetContainer(this, fileCollection.FetchAssets(), virtualFile, collections);
            foreach (IExportCollection collection in collections)
            {
                container.CurrentCollection = collection;
                bool isExported = collection.Export(container, path);
                if (isExported)
                {
                    Logger.Log(LogType.Info, LogCategory.Export, $"'{collection.Name}' exported");
                }
            }
        }
 protected override string ExportInner(ProjectAssetContainer container, string filePath)
 {
     if (m_convert)
     {
         string dirPath  = Path.GetDirectoryName(filePath);
         string fileName = Path.GetFileNameWithoutExtension(filePath);
         filePath = $"{Path.Combine(dirPath, fileName)}.png";
     }
     AssetExporter.Export(container, Asset, filePath);
     return(filePath);
 }
예제 #6
0
        public override bool Export(ProjectAssetContainer container, string dirPath)
        {
            if (m_export.Count == 0)
            {
                return(false);
            }

            string scriptFolder = m_export[0].ExportName;
            string scriptPath   = Path.Combine(dirPath, scriptFolder);

            AssetExporter.Export(container, m_export, scriptPath, OnScriptExported);
            return(true);
        }
예제 #7
0
        public override bool Export(ProjectAssetContainer container, string dirPath)
        {
            string subPath;
            string fileName;

            if (container.TryGetResourcePathFromAssets(Assets, out Object asset, out string subResourcePath))
            {
                string resourcePath = Path.Combine(dirPath, $"{subResourcePath}.{GetExportExtension(asset)}");
                subPath = Path.GetDirectoryName(resourcePath);
                string resFileName = Path.GetFileName(resourcePath);
#warning TODO: combine assets with the same res path into one big asset
                // Unity distinguish assets with non unique path by its type, but file system doesn't support it
                fileName = GetUniqueFileName(subPath, resFileName);
            }
예제 #8
0
        public override bool Export(ProjectAssetContainer container, string dirPath)
        {
            string subPath  = Path.Combine(dirPath, ProjectSettingsName);
            string fileName = $"{Asset.ExportName}.asset";
            string filePath = Path.Combine(subPath, fileName);

            if (!DirectoryUtils.Exists(subPath))
            {
                DirectoryUtils.CreateVirtualDirectory(subPath);
            }

            ExportInner(container, filePath);
            return(true);
        }
예제 #9
0
        protected void ExportAsset(ProjectAssetContainer container, IAssetImporter importer, Object asset, string path, string name)
        {
            if (!DirectoryUtils.Exists(path))
            {
                DirectoryUtils.CreateVirtualDirectory(path);
            }

            string filePath = $"{Path.Combine(path, name)}.{asset.ExportExtension}";

            AssetExporter.Export(container, asset, filePath);
            Meta meta = new Meta(importer, asset.GUID);

            ExportMeta(container, meta, filePath);
        }
예제 #10
0
        protected void ExportAsset(ProjectAssetContainer container, IAssetImporter importer, Object asset, string path, string name)
        {
            if (!DirectoryUtils.Exists(path))
            {
                DirectoryUtils.CreateVirtualDirectory(path);
            }

            string fullName   = $"{name}.{GetExportExtension(asset)}";
            string uniqueName = FileUtils.GetUniqueName(path, fullName, FileUtils.MaxFileNameLength - MetaExtension.Length);
            string filePath   = Path.Combine(path, uniqueName);

            AssetExporter.Export(container, asset, filePath);
            Meta meta = new Meta(importer, asset.GUID);

            ExportMeta(container, meta, filePath);
        }
예제 #11
0
        public override bool Export(ProjectAssetContainer container, string dirPath)
        {
            string subFolder = Asset.ExportName;
            string subPath   = Path.Combine(dirPath, subFolder);
            string fileName  = GetUniqueFileName(container.File, Asset, subPath);
            string filePath  = Path.Combine(subPath, fileName);

            if (!DirectoryUtils.Exists(subPath))
            {
                DirectoryUtils.CreateVirtualDirectory(subPath);
            }

            filePath = ExportInner(container, filePath);
            Meta meta = new Meta(MetaImporter, Asset.GUID);

            ExportMeta(container, meta, filePath);
            return(true);
        }
예제 #12
0
        public override bool Export(ProjectAssetContainer container, string dirPath)
        {
            string folderPath   = Path.Combine(dirPath, Object.AssetsKeyWord, OcclusionCullingSettings.SceneKeyWord);
            string sceneSubPath = GetSceneName(container);
            string fileName     = $"{sceneSubPath}.unity";
            string filePath     = Path.Combine(folderPath, fileName);

            if (IsDuplicate(container))
            {
                if (FileUtils.Exists(filePath))
                {
                    Logger.Log(LogType.Warning, LogCategory.Export, $"Duplicate scene '{sceneSubPath}' has been found. Skipping");
                    return(false);
                }
            }

            folderPath = Path.GetDirectoryName(filePath);
            if (!DirectoryUtils.Exists(folderPath))
            {
                DirectoryUtils.CreateVirtualDirectory(folderPath);
            }

            AssetExporter.Export(container, Components, filePath);
            SceneImporter sceneImporter = new SceneImporter();
            Meta          meta          = new Meta(sceneImporter, GUID);

            ExportMeta(container, meta, filePath);

            string sceneName     = Path.GetFileName(sceneSubPath);
            string subFolderPath = Path.Combine(folderPath, sceneName);

            if (OcclusionCullingData != null)
            {
                OcclusionCullingData.Initialize(container, m_occlusionCullingSettings);
                ExportAsset(container, OcclusionCullingData, subFolderPath);
            }

            return(true);
        }
예제 #13
0
 protected override bool ExportInner(ProjectAssetContainer container, string filePath)
 {
     return(AssetExporter.Export(container, Assets, filePath));
 }
예제 #14
0
 public bool Export(ProjectAssetContainer container, string dirPath)
 {
     return(false);
 }
예제 #15
0
        public override bool Export(ProjectAssetContainer container, string dirPath)
        {
            string subPath  = Path.Combine(dirPath, ProjectSettingsName);
            string fileName = $"{EditorBuildSettings.ClassID.ToString()}.asset";
            string filePath = Path.Combine(subPath, fileName);

            if (!DirectoryUtils.Exists(subPath))
            {
                DirectoryUtils.CreateDirectory(subPath);
            }

            BuildSettings       asset  = (BuildSettings)Asset;
            IEnumerable <Scene> scenes = asset.Scenes.Select(t => new Scene(t, container.SceneNameToGUID(t)));

            EditorBuildSettings.Initialize(scenes);
            AssetExporter.Export(container, EditorBuildSettings, filePath);

            fileName = $"{EditorSettings.ClassID.ToString()}.asset";
            filePath = Path.Combine(subPath, fileName);

            AssetExporter.Export(container, EditorSettings, filePath);

            if (NavMeshProjectSettings != null)
            {
                fileName = $"{NavMeshProjectSettings.ExportName}.asset";
                filePath = Path.Combine(subPath, fileName);

                AssetExporter.Export(container, NavMeshProjectSettings, filePath);
            }
            if (NetworkManager != null)
            {
                fileName = $"{NetworkManager.ExportName}.asset";
                filePath = Path.Combine(subPath, fileName);

                AssetExporter.Export(container, NetworkManager, filePath);
            }
            if (Physics2DSettings != null)
            {
                fileName = $"{Physics2DSettings.ExportName}.asset";
                filePath = Path.Combine(subPath, fileName);

                AssetExporter.Export(container, Physics2DSettings, filePath);
            }
            if (UnityConnectSettings != null)
            {
                fileName = $"{UnityConnectSettings.ExportName}.asset";
                filePath = Path.Combine(subPath, fileName);

                AssetExporter.Export(container, UnityConnectSettings, filePath);
            }
            if (QualitySettings != null)
            {
                fileName = $"{QualitySettings.ExportName}.asset";
                filePath = Path.Combine(subPath, fileName);

                AssetExporter.Export(container, QualitySettings, filePath);
            }

            fileName = $"ProjectVersion.txt";
            filePath = Path.Combine(subPath, fileName);

            using (FileStream file = FileUtils.Create(filePath))
            {
                using (StreamWriter writer = new InvariantStreamWriter(file, Encoding.UTF8))
                {
                    writer.Write("m_EditorVersion: 2017.3.0f3");
                }
            }
            return(true);
        }
예제 #16
0
 public abstract bool Export(ProjectAssetContainer container, string dirPath);
예제 #17
0
        private void ExportAsset(ProjectAssetContainer container, NamedObject asset, string path)
        {
            NativeFormatImporter importer = new NativeFormatImporter(asset);

            ExportAsset(container, importer, asset, path, asset.Name);
        }
 protected override string ExportInner(ProjectAssetContainer container, string filePath)
 {
     AssetExporter.Export(container, Assets, filePath);
     return(filePath);
 }
 protected virtual bool ExportInner(ProjectAssetContainer container, string filePath)
 {
     return(AssetExporter.Export(container, Asset, filePath));
 }
예제 #20
0
 public bool Export(ProjectAssetContainer container, string dirPath)
 {
     Logger.Log(LogType.Warning, LogCategory.Export, $"Unable to export asset {Name}");
     return(false);
 }
예제 #21
0
 protected virtual string ExportInner(ProjectAssetContainer container, string filePath)
 {
     AssetExporter.Export(container, Asset, filePath);
     return(filePath);
 }