private void ActionObjectsUpdated(object sender, Base.StringEventArgs eventArgs) { foreach (ActionObjectButton b in ActionObjectsContent.GetComponentsInChildren <ActionObjectButton>()) { if (b.gameObject.tag == "PersistentButton") { continue; } else { Destroy(b.gameObject); } } foreach (Base.ActionObjectMetadata actionObjectMetadata in Base.ActionsManager.Instance.ActionObjectMetadata.Values) { if (Base.ActionsManager.Instance.ActionObjectMetadata.TryGetValue(actionObjectMetadata.Type, out Base.ActionObjectMetadata actionObject)) { if (actionObject.Abstract) { continue; } } else { continue; } GameObject btnGO = Instantiate(ActionObjectButtonPrefab, ActionObjectsContent.transform); ActionObjectButton btn = btnGO.GetComponent <ActionObjectButton>(); btn.SetLabel(actionObjectMetadata.Type); btn.Button.onClick.AddListener(() => AddObjectToScene(actionObjectMetadata.Type)); btn.RemoveBtn.Button.onClick.AddListener(() => ShowRemoveActionObjectDialog(actionObjectMetadata.Type)); btn.RemoveBtn.SetInteractivity(false, ""); btnGO.transform.SetAsFirstSibling(); if (eventArgs.Data == actionObjectMetadata.Type) { btn.GetComponent <ActionButton>().Highlight(2f); } btn.Button.interactable = !actionObjectMetadata.Disabled; } UpdateRemoveBtns(); }
private void UpdateActionButtonState(bool sceneStarted) { if (sceneStarted) { restoreButtons = true; foreach (ButtonWithTooltip b in ActionObjectsContent.GetComponentsInChildren <ButtonWithTooltip>()) { if (b.gameObject.tag == "ActionObjectButton") { b.SetInteractivity(false, "Objects could not be added when scene is started."); } } } else if (restoreButtons) { restoreButtons = false; ActionObjectsUpdated(this, new StringEventArgs("")); } }
private void ActionObjectsUpdated(object sender, Base.StringEventArgs eventArgs) { foreach (Button b in ActionObjectsContent.GetComponentsInChildren <Button>()) { if (b.gameObject.tag == "PersistentButton") { continue; } else { Destroy(b.gameObject); } } foreach (Base.ActionObjectMetadata actionObjectMetadata in Base.ActionsManager.Instance.ActionObjectMetadata.Values) { if (Base.ActionsManager.Instance.ActionObjectMetadata.TryGetValue(actionObjectMetadata.Type, out Base.ActionObjectMetadata actionObject)) { if (actionObject.Abstract) { continue; } } else { continue; } GameObject btnGO = Instantiate(ButtonPrefab); btnGO.transform.SetParent(ActionObjectsContent.transform); btnGO.transform.localScale = new Vector3(1, 1, 1); Button btn = btnGO.GetComponent <Button>(); btn.GetComponentInChildren <TMPro.TMP_Text>().text = actionObjectMetadata.Type; btn.onClick.AddListener(() => AddObjectToScene(actionObjectMetadata.Type)); btnGO.transform.SetAsFirstSibling(); if (eventArgs.Data == actionObjectMetadata.Type) { btn.GetComponent <ActionButton>().Highlight(2f); } btn.interactable = !actionObjectMetadata.Disabled; } }
public async void UpdateRemoveBtns() { if (GameManager.Instance.GetGameState() != GameManager.GameStateEnum.SceneEditor) { return; } foreach (ActionObjectButton b in ActionObjectsContent.GetComponentsInChildren <ActionObjectButton>()) { if (b == null || b.RemoveBtn == null) { return; } try { await WebsocketManager.Instance.DeleteObjectType(b.GetLabel(), true); b.RemoveBtn.SetInteractivity(true); } catch (RequestFailedException ex) { b.RemoveBtn.SetInteractivity(false, ex.Message); } } }
private void ActionObjectsUpdated(object sender, Base.StringEventArgs eventArgs) { foreach (ActionObjectButton b in ActionObjectsContent.GetComponentsInChildren <ActionObjectButton>()) { if (b.gameObject.tag == "PersistentButton") { continue; } else { Destroy(b.gameObject); } } List <ActionObjectMetadata> orderedList = Base.ActionsManager.Instance.ActionObjectMetadata.Values.ToList(); orderedList.Sort( delegate(ActionObjectMetadata obj1, ActionObjectMetadata obj2) { return(obj2.Type.CompareTo(obj1 .Type)); } ); foreach (Base.ActionObjectMetadata actionObjectMetadata in orderedList) { if (Base.ActionsManager.Instance.ActionObjectMetadata.TryGetValue(actionObjectMetadata.Type, out Base.ActionObjectMetadata actionObject)) { if (actionObject.Abstract) { continue; } } else { continue; } GameObject btnGO = Instantiate(ActionObjectButtonPrefab, ActionObjectsContent.transform); ActionObjectButton btn = btnGO.GetComponent <ActionObjectButton>(); ButtonWithTooltip btnTooltip = btn.Button.GetComponent <ButtonWithTooltip>(); btn.SetLabel(actionObjectMetadata.Type); btn.Button.onClick.AddListener(() => AddObjectToScene(actionObjectMetadata.Type)); btn.RemoveBtn.Button.onClick.AddListener(() => ShowRemoveActionObjectDialog(actionObjectMetadata.Type)); btn.RemoveBtn.SetInteractivity(false, ""); btnGO.transform.SetAsFirstSibling(); if (eventArgs.Data == actionObjectMetadata.Type) { btn.GetComponent <ActionButton>().Highlight(2f); } if (SceneManager.Instance.SceneStarted) { btnTooltip.SetInteractivity(false, "Objects could not be added when scene is started"); } else { btnTooltip.SetInteractivity(!actionObjectMetadata.Disabled, actionObjectMetadata.Problem); } } UpdateRemoveBtns(); }