Ejemplo n.º 1
0
        private void SpaceUpdated(Core.Space sender, Core.Space.Process[] processSet, Core.Space.Process endedProcess)
        {
            if (endedProcess == Core.Space.Process.Fetching)
            {
                assetsUpdated = true;
            }

            if (endedProcess == Core.Space.Process.Deleting)
            {
                sender.onProcessEnd -= SpaceUpdated;
            }

            if (endedProcess == Core.Space.Process.FetchingGraph)
            {
                if (selectedSpace != null && selectedSpace.isGraphFetched)
                {
                    SpaceGraphEditor.OpenGraphEditor(selectedSpace.Graph);
                }
            }
        }
Ejemplo n.º 2
0
        void DrawAssociatedAssetsPanel()
        {
            if (selectedSpace != null && selectedSpace.assetIDs != null)
            {
                Color bgColor = GUI.backgroundColor;

                GUI.backgroundColor = BG_COLOR_EVEN;

                EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.MinHeight(SPACE_ASSET_PANEL_MIN_HEIGHT));
                {
                    int removeAsset = -1;

                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Space Name", GUILayout.Width(SPACE_BUTTON_WIDTH));
                        updatedSpaceName = GUILayout.TextField(updatedSpaceName);

                        bool wasEnabled = GUI.enabled;
                        GUI.enabled = wasEnabled && updatedSpaceName != selectedSpace.name;
                        if (GUILayout.Button("Update Name", GUILayout.Width(SPACE_WIDE_BUTTON_WIDTH)))
                        {
                            selectedSpace.Update(updatedSpaceName, "");
                        }
                        GUI.enabled = wasEnabled;
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Space ID", GUILayout.Width(SPACE_BUTTON_WIDTH));
                        EditorGUILayout.SelectableLabel(selectedSpace.id, GUILayout.Width(ASSET_ID_WIDTH), GUILayout.Height(EditorStyles.label.lineHeight + 1));
                        GUILayout.Label("", GUILayout.ExpandWidth(true));

                        if (GUILayout.Button("Edit Space Graph", GUILayout.Width(SPACE_WIDE_BUTTON_WIDTH)))
                        {
                            SpaceGraphEditor.OpenGraphEditor(selectedSpace);
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Asset Name", GUILayout.Width(ASSET_NAME_WIDTH));
                        GUILayout.Label("Asset Type", GUILayout.Width(ASSET_TYPE_WIDTH));
                        GUILayout.Label("Asset ID", GUILayout.Width(ASSET_ID_WIDTH));
                        GUILayout.Label("");

                        if (GUILayout.Button("Add Assets", GUILayout.Width(SPACE_WIDE_BUTTON_WIDTH)))
                        {
                            SelectAssetDialog.Init(selectedSpace, assets);
                        }

                        //TODO: Add a Remove All button.
                    }
                    EditorGUILayout.EndHorizontal();

                    scrollPosSpaceAssets = EditorGUILayout.BeginScrollView(scrollPosSpaceAssets, EditorStyles.helpBox);
                    {
                        if (selectedSpace.Assets != null && selectedSpace.Assets.Count > 0)
                        {
                            for (int j = 0; j < selectedSpace.Assets.Count; j++)
                            {
                                EditorGUILayout.BeginHorizontal();
                                {
                                    if (string.IsNullOrEmpty(selectedSpace.Assets[j].name))
                                    {
                                        DrawStatus(new Core.StatusMessage()
                                        {
                                            statusMessage = "", progressing = true
                                        });                                                                             //selectedSpace.Assets[j].GetStatusMessage());
                                    }
                                    else
                                    {
                                        GUILayout.Label(selectedSpace.Assets[j].name, GUILayout.Width(ASSET_NAME_WIDTH));
                                    }

                                    GUILayout.Label(selectedSpace.Assets[j].assetType, GUILayout.Width(ASSET_TYPE_WIDTH));
                                    EditorGUILayout.SelectableLabel(selectedSpace.assetIDs[j], GUILayout.Width(ASSET_ID_WIDTH), GUILayout.Height(EditorStyles.label.lineHeight + 1));

                                    if (GUILayout.Button("Remove"))
                                    {
                                        removeAsset = j;
                                    }
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                        else
                        {
                            for (int j = 0; j < selectedSpace.assetIDs.Count; j++)
                            {
                                EditorGUILayout.BeginHorizontal();
                                {
                                    GUILayout.Label(!string.IsNullOrEmpty(assets[j].name) ? assets[j].name : "...", GUILayout.Width(ASSET_NAME_WIDTH));
                                    GUILayout.Label(!string.IsNullOrEmpty(assets[j].assetType) ? assets[j].assetType : "...", GUILayout.Width(ASSET_TYPE_WIDTH));
                                    EditorGUILayout.SelectableLabel(selectedSpace.assetIDs[j], GUILayout.Width(ASSET_ID_WIDTH), GUILayout.Height(EditorStyles.label.lineHeight + 1));

                                    if (GUILayout.Button("Remove"))
                                    {
                                        removeAsset = j;
                                    }
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                        }

                        if (removeAsset > -1)
                        {
                            var assetToRemove = selectedSpace.Assets[removeAsset];

                            if (selectedSpace.Assets.Remove(selectedSpace.Assets[removeAsset]))
                            {
                                selectedSpace.RemoveAsset(assetToRemove);
                            }
                        }
                    }
                    EditorGUILayout.EndScrollView();
                }
                EditorGUILayout.EndVertical();
                GUI.backgroundColor = bgColor;
            }
        }