public override void OnInspectorGUI() { EditorGUILayout.BeginVertical(); bool click = false; if (m_isSyncRequired) { EditorGUILayout.HelpBox("One or more prefabs have been changed. AssetLibrary need to be synchronized.", MessageType.Warning); click = GUILayout.Button("Synchronize"); } m_projectGUI.OnGUI(); EditorGUILayout.Space(); m_assetsGUI.OnGUI(); EditorGUILayout.Space(); if (click) { Asset.Sync(); m_assetsGUI = new AssetLibraryAssetsGUI(); m_assetsGUI.InitIfNeeded(); m_assetsGUI.SetSelectedFolders(m_projectGUI.SelectedFolders); m_assetsGUI.OnEnable(); m_isSyncRequired = false; SaveAsset(); } EditorGUILayout.EndVertical(); }
public override void OnInspectorGUI() { EditorGUILayout.BeginVertical(); bool click = false; if (m_isSyncRequired) { EditorGUILayout.HelpBox("One or more prefabs have been changed. AssetLibrary need to be synchronized.", MessageType.Warning); click = GUILayout.Button("Synchronize"); } m_projectGUI.OnGUI(); m_assetsGUI.OnGUI(); //EditorGUI.BeginChangeCheck(); //EditorGUILayout.Space(); // EditorGUILayout.BeginHorizontal(); //Asset.KeepRuntimeProjectInSync = EditorGUILayout.Toggle("Keep in sync", Asset.KeepRuntimeProjectInSync); //EditorGUILayout.EndHorizontal(); // if (Asset.KeepRuntimeProjectInSync) //{ // EditorGUILayout.HelpBox("Runtime project tree will be updated each time you launch runtime editor and will reflect all changes in this asset library", MessageType.Info); //} //if(EditorGUI.EndChangeCheck()) //{ // SaveAsset(); //} EditorGUILayout.Space(); //EditorGUILayout.BeginHorizontal(); //GUILayout.FlexibleSpace(); //GUILayout.Button("Create Reference", GUILayout.Width(100)); //EditorGUILayout.EndHorizontal(); if (click) { Asset.Sync(); m_assetsGUI = new AssetLibraryAssetsGUI(); m_assetsGUI.InitIfNeeded(); m_assetsGUI.SetSelectedFolders(m_projectGUI.SelectedFolders); m_assetsGUI.OnEnable(); m_isSyncRequired = false; SaveAsset(); } EditorGUILayout.EndVertical(); }
private void OnEnable() { if (m_assetsGUI == null) { m_assetsGUI = new AssetLibraryAssetsGUI(); m_assetsGUI.SetTreeAsset(Asset); } if (m_projectGUI == null) { m_projectGUI = new AssetLibraryProjectGUI(m_assetsGUI); m_projectGUI.SetTreeAsset(Asset); m_projectGUI.SelectedFoldersChanged += OnSelectedFoldersChanged; m_isSyncRequired = Asset.IsSyncRequired(); } m_assetsGUI.SetSelectedFolders(m_projectGUI.SelectedFolders); m_projectGUI.OnEnable(); m_assetsGUI.OnEnable(); }
private static void CreateAssetLibrary(object[] objects, string folderName, string assetLibraryName, int index, AssetLibraryAsset asset, AssetFolderInfo folder, HashSet <UnityObject> hs) { int identity = asset.AssetLibrary.Identity; foreach (object o in objects) { UnityObject obj = o as UnityObject; if (!obj) { if (o != null) { Debug.Log(o.GetType() + " is not a UnityEngine.Object"); } continue; } if (hs.Contains(obj)) { continue; } if (!AssetDatabase.Contains(obj)) { continue; } if (obj is GameObject) { GameObject go = (GameObject)obj; AssetInfo assetInfo = new AssetInfo(go.name, 0, identity); assetInfo.Object = go; hs.Add(go); identity++; List <PrefabPartInfo> prefabParts = new List <PrefabPartInfo>(); AssetLibraryAssetsGUI.CreatePefabParts(go, ref identity, prefabParts); for (int i = prefabParts.Count - 1; i >= 0; --i) { PrefabPartInfo prefabPart = prefabParts[i]; if (hs.Contains(prefabPart.Object)) { prefabParts.Remove(prefabPart); } else { hs.Add(prefabPart.Object); } } 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, folderName, assetLibraryName, index); index++; asset = ScriptableObject.CreateInstance <AssetLibraryAsset>(); folder = asset.AssetLibrary.Folders.Where(f => f.depth == 0).First(); if (folder.Assets == null) { folder.Assets = new List <AssetInfo>(); } identity = asset.AssetLibrary.Identity; } assetInfo.PrefabParts = prefabParts; asset.AssetLibrary.Identity = identity; folder.Assets.Add(assetInfo); assetInfo.Folder = folder; } else { AssetInfo assetInfo = new AssetInfo(obj.name, 0, identity); assetInfo.Object = obj; identity++; if (identity >= AssetLibraryInfo.MAX_ASSETS) { SaveAssetLibrary(asset, folderName, assetLibraryName, index); index++; asset = ScriptableObject.CreateInstance <AssetLibraryAsset>(); folder = asset.AssetLibrary.Folders.Where(f => f.depth == 0).First(); if (folder.Assets == null) { folder.Assets = new List <AssetInfo>(); } identity = asset.AssetLibrary.Identity; } asset.AssetLibrary.Identity = identity; folder.Assets.Add(assetInfo); assetInfo.Folder = folder; } } SaveAssetLibrary(asset, folderName, assetLibraryName, index); index++; //Selection.activeObject = asset; //EditorGUIUtility.PingObject(asset); }
public AssetLibraryProjectGUI(AssetLibraryAssetsGUI assetsGUI) { m_assetsGUI = assetsGUI; }