コード例 #1
0
        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();
        }
コード例 #2
0
        public override void OnInspectorGUI()
        {
            //if(!EditorApplication.isPlaying && EditorApplication.isPlayingOrWillChangePlaymode)
            //{
            //    return;
            //}

            EditorGUILayout.BeginVertical();
            if (m_isSyncRequired)
            {
                EditorGUILayout.HelpBox("One or more prefabs have been changed. AssetLibrary need to be synchronized.", MessageType.Warning);
                if (GUILayout.Button("Synchronize"))
                {
                    Asset.Sync();
                    m_assetsGUI = new AssetLibraryAssetsGUI();
                    m_assetsGUI.InitIfNeeded();
                    m_assetsGUI.SetSelectedFolders(m_projectGUI.SelectedFolders);
                    m_assetsGUI.OnEnable();
                    m_isSyncRequired = false;
                    SaveAsset();
                }
            }


            //bool canRenderAssetsGUI =  m_canRenderAssetsGUI;
            m_projectGUI.OnGUI();
            //if(canRenderAssetsGUI)
            {
                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.EndVertical();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
ファイル: Menu.cs プロジェクト: midgithub/Unity_RuntimeEditor
        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);
        }
コード例 #5
0
 public AssetLibraryProjectGUI(AssetLibraryAssetsGUI assetsGUI)
 {
     m_assetsGUI = assetsGUI;
 }