private static void CreateAssetLibraryForScene(Scene scene, int index, AssetLibraryAsset asset, AssetFolderInfo folder, HashSet <UnityObject> hs) { TypeMap typeMap = new TypeMap(); AssetDB assetDB = new AssetDB(); RuntimeShaderUtil shaderUtil = new RuntimeShaderUtil(); IOC.Register <ITypeMap>(typeMap); IOC.Register <IAssetDB>(assetDB); IOC.Register <IRuntimeShaderUtil>(shaderUtil); PersistentRuntimeScene rtScene = new PersistentRuntimeScene(); GetDepsFromContext ctx = new GetDepsFromContext(); rtScene.GetDepsFrom(scene, ctx); Queue <UnityObject> depsQueue = new Queue <UnityObject>(ctx.Dependencies.OfType <UnityObject>()); GetDepsFromContext getDepsCtx = new GetDepsFromContext(); while (depsQueue.Count > 0) { UnityObject uo = depsQueue.Dequeue(); if (!uo) { continue; } Type persistentType = typeMap.ToPersistentType(uo.GetType()); if (persistentType != null) { getDepsCtx.Clear(); try { PersistentObject persistentObject = (PersistentObject)Activator.CreateInstance(persistentType); //persistentObject.ReadFrom(uo); persistentObject.GetDepsFrom(uo, getDepsCtx); } catch (Exception e) { Debug.LogError(e); } foreach (UnityObject dep in getDepsCtx.Dependencies) { if (!ctx.Dependencies.Contains(dep)) { ctx.Dependencies.Add(dep); depsQueue.Enqueue(dep); } } } } IOC.Unregister <IRuntimeShaderUtil>(shaderUtil); IOC.Unregister <ITypeMap>(typeMap); IOC.Unregister <IAssetDB>(assetDB); CreateAssetLibrary(ctx.Dependencies.ToArray(), "Scenes/" + scene.name, "SceneAssetLibrary", index, asset, folder, hs); }
private static void CreateAssetLibraryForScene(Scene scene, int index, AssetLibraryAsset asset, AssetFolderInfo folder, HashSet <UnityObject> hs) { TypeMap typeMap = new TypeMap(); AssetDB assetDB = new AssetDB(); IOC.Register <ITypeMap>(typeMap); IOC.Register <IAssetDB>(assetDB); PersistentRuntimeScene rtScene = new PersistentRuntimeScene(); GetDepsFromContext ctx = new GetDepsFromContext(); rtScene.GetDepsFrom(scene, ctx); IOC.Unregister <ITypeMap>(typeMap); IOC.Unregister <IAssetDB>(assetDB); CreateAssetLibrary(ctx.Dependencies.ToArray(), "Scenes/" + scene.name, "SceneAssetLibrary", index, asset, folder, hs); }