public async void NewProject() { string name = NewProjectName.GetValue()?.ToString(); string sceneName; bool generateLogic; try { sceneName = GetSelectedValue(ToggleGroup); string sceneId = Base.GameManager.Instance.GetSceneId(sceneName); generateLogic = GenerateLogicToggle.GetComponent <Toggle>().isOn; await Base.GameManager.Instance.NewProject(name, sceneId, generateLogic); Close(); } catch (Exception ex) when(ex is Base.ItemNotFoundException || ex is Base.RequestFailedException) { Base.Notifications.Instance.ShowNotification("Failed to create new project", ex.Message); } }
public async Task <Base.RequestResult> ValidateFields() { string name = NewProjectName.GetValue()?.ToString(); string sceneName; string sceneId; bool generateLogic = GenerateLogicToggle.GetComponent <Toggle>().isOn; if (string.IsNullOrEmpty(name)) { return(false, "Name cannot be empty"); } try { sceneName = GetSelectedValue(ToggleGroup); sceneId = Base.GameManager.Instance.GetSceneId(sceneName); } catch (Base.ItemNotFoundException ex) { return(false, "No scene selected"); } try { await Base.WebsocketManager.Instance.CreateProject(name, sceneId, "", generateLogic, true); } catch (Base.RequestFailedException ex) { return(false, ex.Message); } return(true, ""); }