void CreatePortal(Core.Space space) { var portal = new GameObject("Portal (" + space.id + ")"); var portalWidget = portal.AddComponent <Core.PortalWidget>(); portalWidget.generateHotspot = false; portalWidget.Initialize(space); portalWidget.LoadOnStart = true; }
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 Init(Core.Space selectedObject, List <Core.Asset> itemList)//, ProcessSelection<T2> selectionProcess = null) { var window = GetWindow <SelectAssetDialog>("Select Assets"); window.position = new Rect(Screen.width / 2, Screen.height / 2, 800, 600); window.selectedSpace = selectedObject; window.assets = itemList; window.selectedAssets = new List <Core.Asset>(); //window.processSelection = selectionProcess; window.ShowPopup(); }
protected virtual void InitializeSpaceEntry(Core.Space space) { GameObject spaceEntry = Instantiate <GameObject>(SpaceEntryPrefab, SpacesPanel.transform, false); spaceEntry.GetComponentInChildren <Text>().text = space.name; var button = spaceEntry.GetComponent <Button>(); button.gameObject.name = space.name; button.onClick.AddListener(delegate { Space_Click(space); }); spaceEntry.SetActive(true); }
void DrawCreateSpacePanel() { EditorGUILayout.BeginVertical(EditorStyles.helpBox); { EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Space Name:", GUILayout.Width(160)); spaceName = EditorGUILayout.TextField(spaceName); } EditorGUILayout.EndHorizontal(); GUILayout.Label("", GUILayout.ExpandHeight(true)); if (m_space == null) { GUILayout.Label(""); } else { DrawStatus(m_space.GetStatusMessage()); } EditorGUILayout.BeginHorizontal(); { GUILayout.Label(""); bool wasEndabled = GUI.enabled; GUI.enabled = wasEndabled && m_space == null && !string.IsNullOrEmpty(spaceName); if (GUILayout.Button("Create Space", GUILayout.Width(120))) { wasCreateCalled = true; m_space = Core.Space.Create(spaceName); } GUI.enabled = wasEndabled; if (GUILayout.Button("Close", GUILayout.Width(120))) { if (wasCreateCalled) { GetWindow <SpaceManagerWindow>().RefreshSpacesList(); } Close(); } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); }
void LoadSpaceInEditor(Core.Space space) { if (!EditorApplication.isPlaying) { EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects); EditorApplication.isPlaying = true; } if (!FindObjectOfType <UnityClient.UserSession>()) { Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>("Assets/_Spaces SDK/Examples/Prefabs/User Session [Debug].prefab")); } //space.Enter(); CreatePortal(space); }
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); } } }
public static void OpenGraphEditor(Core.Space space) { var window = GetWindow <SpaceGraphEditor>(); if (space != null) { window.space = space; window.SubscribeToSpace(); if (space.isGraphFetched) { window.graph = space.Graph; window.InitializeGraph(); } else { window.space.FetchGraph(); } } }
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) { } }