private static void CreateAssetLibraryFromScene(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); int identity = asset.AssetLibrary.Identity; foreach (UnityObject obj in ctx.Dependencies) { if (hs.Contains(obj)) { continue; } if (obj is GameObject) { GameObject go = (GameObject)obj; if (go.IsPrefab()) { AssetInfo assetInfo = new AssetInfo(go.name, 0, identity); assetInfo.Object = go; identity++; List <PrefabPartInfo> prefabParts = new List <PrefabPartInfo>(); AssetLibraryAssetsGUI.CreatePefabParts(go, ref identity, prefabParts); if (prefabParts.Count >= AssetLibraryInfo.MAX_ASSETS - AssetLibraryInfo.INITIAL_ID) { EditorUtility.DisplayDialog("Unable Create AssetLibrary", string.Format("Max 'Indentity' value reached. 'Identity' == {0}", AssetLibraryInfo.MAX_ASSETS), "OK"); return; } if (identity >= AssetLibraryInfo.MAX_ASSETS) { SaveAssetLibrary(asset, scene, index); index++; asset = ScriptableObject.CreateInstance <AssetLibraryAsset>(); folder = asset.AssetLibrary.Folders.Where(f => f.depth == 0).First(); identity = asset.AssetLibrary.Identity; } assetInfo.PrefabParts = prefabParts; asset.AssetLibrary.Identity = identity; folder.Assets.Add(assetInfo); } } else { AssetInfo assetInfo = new AssetInfo(obj.name, 0, identity); assetInfo.Object = obj; identity++; if (identity >= AssetLibraryInfo.MAX_ASSETS) { SaveAssetLibrary(asset, scene, index); index++; asset = ScriptableObject.CreateInstance <AssetLibraryAsset>(); folder = asset.AssetLibrary.Folders.Where(f => f.depth == 0).First(); identity = asset.AssetLibrary.Identity; } asset.AssetLibrary.Identity = identity; folder.Assets.Add(assetInfo); } } SaveAssetLibrary(asset, scene, index); index++; Selection.activeObject = asset; EditorGUIUtility.PingObject(asset); }