void SpaceUpdated(Core.Space sender, Core.Space.Process[] processSet, Core.Space.Process endedProcess) { if (endedProcess == Core.Space.Process.FetchingGraph) { graph = sender.Graph; //metadata = JsonUtility.ToJson(graph, true); InitializeGraph(); } }
public static void OpenGraphEditor(Core.SpaceGraph spaceGraph) { var window = GetWindow <SpaceGraphEditor>(); window.spaceTitle = ""; window.graph = spaceGraph; if (EditorApplication.isPlayingOrWillChangePlaymode && UnityClient.UserSession.Instance != null) { window.space = UnityClient.UserSession.Instance.CurrentSpace; } window.InitializeGraph(); }
void OnGUI() { EditorGUILayout.BeginVertical(); { GUILayout.Label(""); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Space Name", GUILayout.Width(100)); if (space == null) { spaceTitle = EditorGUILayout.TextField(spaceTitle, GUILayout.ExpandWidth(true)); bool wasEndabled = GUI.enabled; GUI.enabled = wasEndabled && !wasCreateCalled && !string.IsNullOrEmpty(spaceTitle); if (GUILayout.Button("Create Space", GUILayout.Width(140))) { wasCreateCalled = true; space = Core.Space.Create(spaceTitle); } GUI.enabled = wasEndabled; } else { EditorGUILayout.SelectableLabel(space.name); GUILayout.Label("", GUILayout.ExpandWidth(true)); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Space ID", GUILayout.Width(100)); EditorGUILayout.SelectableLabel(space == null ? "" : space.id, GUILayout.Height(EditorStyles.label.lineHeight + 1)); GUILayout.Label("", GUILayout.ExpandWidth(true)); } EditorGUILayout.EndHorizontal(); GUILayout.Label(""); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, EditorStyles.helpBox); { if (graph != null) { assetsExpanded = EditorGUILayout.Foldout(assetsExpanded, "Assets:"); if (graph.assetIDs != null & assetsExpanded) { for (int i = 0; i < graph.assetIDs.Count; i++) { using (var assetListPanel = new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { using (var assetPanel = new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button("X", GUILayout.Width(20))) { if (toDelete == null) { toDelete = new List <string>(); } toDelete.Add(graph.assetIDs[i]); } //GUILayout.Label("Asset ID:", GUILayout.Width(80)); EditorGUILayout.SelectableLabel(graph.assetIDs[i], GUILayout.Height(EditorStyles.label.lineHeight + 1)); } } } if (toDelete != null) { toDelete.ForEach(id => graph.assetIDs.Remove(id)); } } if (graph.nodes != null) { foreach (Core.Node node in graph.nodes) { SpaceGraphNodeViewer.DrawNodeEditor(node, ref nodeWidgetExpandState); } } } //if (nodes != null) //{ // //metadata = EditorGUILayout.TextArea(metadata, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)); // for (int i = 0; i < nodes.Count; i++) // { // nodes[i] = EditorGUILayout.TextArea(nodes[i]); // } //} } EditorGUILayout.EndScrollView(); EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button("Refresh", GUILayout.Width(140))) { graph = Core.SpaceGraph.Generate(); } GUILayout.Label("", GUILayout.ExpandWidth(true)); regularColor = GUI.color; if (metadataFormatError) { GUI.color = errorColor; } bool wasEnabled = GUI.enabled; GUI.enabled = wasEnabled && space != null && !metadataFormatError; if (GUILayout.Button("Update Space Graph", GUILayout.Width(140))) { if (UpdateSpaceGraph()) { metadataFormatError = false; } else { metadataFormatError = true; } } GUI.enabled = wasEnabled; GUI.color = regularColor; if (GUILayout.Button("Close", GUILayout.Width(140))) { Close(); } } EditorGUILayout.EndHorizontal(); GUILayout.Label(""); } EditorGUILayout.EndVertical(); // We force a repaint so we can run the httpmanager while in editor mode. BestHTTP.HTTPManager.OnUpdate(); try { this.Repaint(); } catch (System.Exception ex) { } }