public override bool Export(ProjectAssetContainer container, string dirPath)
        {
            TryInitialize(container);

            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.CreateDirectory(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)
            {
                ExportAsset(container, OcclusionCullingData, subFolderPath);
            }

            return(true);
        }
 public void Export(ProjectAssetContainer container, IEnumerable <Object> assets, string path)
 {
     foreach (Object asset in assets)
     {
         Export(container, asset, path);
     }
 }
        private void TryInitialize(ProjectAssetContainer container)
        {
            if (m_initialized)
            {
                return;
            }

            foreach (Object comp in Components)
            {
                if (comp.ClassID == ClassIDType.OcclusionCullingSettings)
                {
                    OcclusionCullingSettings settings = (OcclusionCullingSettings)comp;
                    if (OcclusionCullingSettings.IsReadPVSData(File.Version))
                    {
                        if (settings.PVSData.Count > 0)
                        {
                            OcclusionCullingData = new OcclusionCullingData(container.VirtualFile);
                            OcclusionCullingData.Initialize(container, settings);
                        }
                    }
                }
            }

            m_initialized = true;
        }
        public override bool Export(ProjectAssetContainer container, string dirPath)
        {
            string folderPath = Path.Combine(dirPath, OcclusionCullingSettings.SceneExportFolder);
            string fileName   = $"{Name}.unity";
            string filePath   = Path.Combine(folderPath, fileName);

            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }

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

            ExportMeta(container, meta, filePath);

            string subFolderPath = Path.Combine(folderPath, Name);

            if (OcclusionCullingData != null)
            {
                ExportAsset(container, OcclusionCullingData, subFolderPath);
            }
            if (LightingDataAsset != null)
            {
                ExportAsset(container, OcclusionCullingData, subFolderPath);
            }
            if (m_navMeshData != null)
            {
                ExportAsset(container, m_navMeshData, subFolderPath);
            }

            return(true);
        }
 public void Export(ProjectAssetContainer container, Object asset, string path)
 {
     using (FileStream fileStream = new FileStream(path, FileMode.CreateNew, FileAccess.Write))
     {
         container.File = asset.File;
         asset.ExportBinary(container, fileStream);
     }
 }
Example #6
0
        public void Export(string path, IEnumerable <Object> objects)
        {
            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(objects);
            depSet.UnionWith(depList);
            for (int i = 0; i < depList.Count; i++)
            {
                Object current = depList[i];
                if (!queued.Contains(current))
                {
                    IAssetExporter    exporter   = m_exporters[current.ClassID];
                    IExportCollection collection = exporter.CreateCollection(current);

                    foreach (Object element in collection.Objects)
                    {
                        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 current.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, 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);
 }
Example #8
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);
        }
        protected void ExportAsset(ProjectAssetContainer container, IAssetImporter importer, Object asset, string path, string name)
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(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);
        }
Example #10
0
        public override bool Export(ProjectAssetContainer container, string dirPath)
        {
            string subPath  = Path.Combine(dirPath, "ProjectSettings");
            string fileName = $"{Asset.GetType().Name}.asset";
            string filePath = Path.Combine(subPath, fileName);

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

            ExportInner(container, filePath);
            return(true);
        }
Example #11
0
 public void Export(ProjectAssetContainer container, Object asset, string path)
 {
     using (FileStream fileStream = File.Open(path, FileMode.Create, FileAccess.Write))
     {
         using (StreamWriter streamWriter = new StreamWriter(fileStream))
         {
             YAMLWriter writer = new YAMLWriter();
             container.File = asset.File;
             YAMLDocument doc = asset.ExportYAMLDocument(container);
             writer.AddDocument(doc);
             writer.Write(streamWriter);
         }
     }
 }
        protected void ExportMeta(ProjectAssetContainer container, Meta meta, string filePath)
        {
            string metaPath = $"{filePath}.meta";

            using (FileStream fileStream = System.IO.File.Open(metaPath, FileMode.Create, FileAccess.Write))
            {
                using (StreamWriter streamWriter = new StreamWriter(fileStream))
                {
                    YAMLWriter   writer = new YAMLWriter();
                    YAMLDocument doc    = meta.ExportYAMLDocument(container);
                    writer.IsWriteDefaultTag = false;
                    writer.IsWriteVersion    = false;
                    writer.AddDocument(doc);
                    writer.Write(streamWriter);
                }
            }
        }
        public override bool Export(ProjectAssetContainer container, string dirPath)
        {
            string subFolder = Asset.ExportName;
            string subPath   = Path.Combine(dirPath, subFolder);
            string fileName  = GetUniqueFileName(Asset, subPath);
            string filePath  = Path.Combine(subPath, fileName);

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

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

            ExportMeta(container, meta, filePath);
            return(true);
        }
        private void TryInitialize(ProjectAssetContainer container)
        {
            if (m_initialized)
            {
                return;
            }

            foreach (Object comp in Components)
            {
                switch (comp.ClassID)
                {
                case ClassIDType.NavMeshSettings:
                {
                    NavMeshSettings settings = (NavMeshSettings)comp;
                    NavMeshData = settings.NavMeshData.FindObject(File);
                }
                break;

                case ClassIDType.OcclusionCullingSettings:
                {
                    OcclusionCullingSettings settings = (OcclusionCullingSettings)comp;
                    if (OcclusionCullingSettings.IsReadPVSData(File.Version))
                    {
                        if (settings.PVSData.Count > 0)
                        {
                            OcclusionCullingData = new OcclusionCullingData(container.VirtualFile);
                            OcclusionCullingData.Initialize(container, (byte[])settings.PVSData, settings.SceneGUID, settings.StaticRenderers, settings.Portals);
                        }
                    }
                }
                break;
                }
            }

            m_initialized = true;
        }
Example #15
0
 protected override string ExportInner(ProjectAssetContainer container, string filePath)
 {
     TryInitialize(container);
     return(base.ExportInner(container, filePath));
 }
Example #16
0
 public void Export(ProjectAssetContainer container, IEnumerable <Object> assets, string path)
 {
 }
        private void ExportAsset(ProjectAssetContainer container, NamedObject asset, string path)
        {
            NativeFormatImporter importer = new NativeFormatImporter(asset);

            ExportAsset(container, importer, asset, path, asset.Name);
        }
Example #18
0
 public void Export(ProjectAssetContainer container, Object asset, string path)
 {
 }
 protected virtual string ExportInner(ProjectAssetContainer container, string filePath)
 {
     AssetExporter.Export(container, Asset, filePath);
     return(filePath);
 }
 public abstract bool Export(ProjectAssetContainer container, string dirPath);
 protected override string ExportInner(ProjectAssetContainer container, string filePath)
 {
     AssetExporter.Export(container, Objects, filePath);
     return(filePath);
 }
Example #22
0
 public bool Export(ProjectAssetContainer container, string dirPath)
 {
     return(false);
 }
Example #23
0
        private void TryInitialize(ProjectAssetContainer container)
        {
            if (m_initialized)
            {
                return;
            }

            AnimatorController asset      = (AnimatorController)Asset;
            ControllerConstant controller = asset.Controller;
            IReadOnlyList <OffsetPtr <StateMachineConstant> > stateMachinesConst = controller.StateMachineArray;

            m_stateMachines = new AnimatorStateMachine[stateMachinesConst.Count];
            for (int i = 0; i < stateMachinesConst.Count; i++)
            {
                StateMachineConstant stateMachineConstant = stateMachinesConst[i].Instance;
                AnimatorStateMachine stateMachine         = new AnimatorStateMachine(container.VirtualFile, asset, i);
                m_stateMachines[i] = stateMachine;
            }

            for (int i = 0; i < StateMachines.Count; i++)
            {
                AnimatorStateMachine stateMachine         = StateMachines[i];
                StateMachineConstant stateMachineConstant = asset.Controller.StateMachineArray[i].Instance;
                AddAsset(stateMachine);

                foreach (PPtr <AnimatorStateTransition> transitionPtr in stateMachine.AnyStateTransitions)
                {
                    AnimatorStateTransition transition = transitionPtr.GetAsset(container.VirtualFile);
                    AddAsset(transition);
                }
                foreach (PPtr <AnimatorTransition> transitionPtr in stateMachine.EntryTransitions)
                {
                    AnimatorTransition transition = transitionPtr.GetAsset(container.VirtualFile);
                    AddAsset(transition);
                }

                for (int j = 0; j < stateMachine.ChildStates.Count; j++)
                {
                    PPtr <AnimatorState> statePtr      = stateMachine.ChildStates[j].State;
                    AnimatorState        state         = statePtr.GetAsset(container.VirtualFile);
                    StateConstant        stateConstant = stateMachineConstant.StateConstantArray[j].Instance;
                    AddAsset(state);

                    if (state.Motion.IsVirtual)
                    {
                        AddBlendTree(container.VirtualFile, state.Motion.CastTo <BlendTree>());
                    }

                    for (int k = 0; k < state.Transitions.Count; k++)
                    {
                        PPtr <AnimatorStateTransition> transitionPtr      = state.Transitions[k];
                        AnimatorStateTransition        transition         = transitionPtr.GetAsset(container.VirtualFile);
                        TransitionConstant             transitionConstant = stateConstant.TransitionConstantArray[k].Instance;

                        AddAsset(transition);
                    }
                }
            }

            m_initialized = true;
        }