protected async virtual Task UpdateBtns(InteractiveObject obj) { if (CanvasGroup.alpha == 0) { return; } UpdateRobotSelectorAndSteppingButtons(); if (requestingObject || obj == null) { SelectedObjectText.text = ""; MoveButton.SetInteractivity(false, $"{MOVE_BTN_LABEL}\n(no object selected)"); MoveButton2.SetInteractivity(false, $"{MOVE_BTN_LABEL}\n(no object selected)"); RemoveButton.SetInteractivity(false, $"{REMOVE_BTN_LABEL}\n(no object selected)"); RenameButton.SetInteractivity(false, $"{RENAME_BTN_LABEL}\n(no object selected)"); CalibrationButton.SetInteractivity(false, $"{CALIBRATION_BTN_LABEL}\n(no object selected)"); OpenMenuButton.SetInteractivity(false, $"{OPEN_MENU_BTN_LABEL}\n(no object selected)"); } else if (obj.IsLocked && obj.LockOwner != LandingScreen.Instance.GetUsername()) { SelectedObjectText.text = obj.GetName() + "\n" + obj.GetObjectTypeName(); MoveButton.SetInteractivity(false, $"{MOVE_BTN_LABEL}\n(object is used by {obj.LockOwner})"); MoveButton2.SetInteractivity(false, $"{MOVE_BTN_LABEL}\n(object is used by {obj.LockOwner})"); RemoveButton.SetInteractivity(false, $"{REMOVE_BTN_LABEL}\n(object is used by {obj.LockOwner})"); RenameButton.SetInteractivity(false, $"{RENAME_BTN_LABEL}\n(object is used by {obj.LockOwner})"); CalibrationButton.SetInteractivity(false, $"{CALIBRATION_BTN_LABEL}\n(object is used by {obj.LockOwner})"); OpenMenuButton.SetInteractivity(false, $"{OPEN_MENU_BTN_LABEL}\n(object is used by {obj.LockOwner})"); } else { SelectedObjectText.text = obj.GetName() + "\n" + obj.GetObjectTypeName(); MoveButton.SetInteractivity(false, $"{MOVE_BTN_LABEL}\n(loading...)"); MoveButton2.SetInteractivity(false, $"{MOVE_BTN_LABEL}\n(loading...)"); RemoveButton.SetInteractivity(false, $"{REMOVE_BTN_LABEL}\n(loading...)"); Task <RequestResult> tMove = Task.Run(() => obj.Movable()); Task <RequestResult> tRemove = Task.Run(() => obj.Removable()); UpdateMoveAndRemoveBtns(selectedObject.GetId(), tMove, tRemove); RenameButton.SetInteractivity(obj.GetType() == typeof(ActionPoint3D) || obj.GetType() == typeof(Action3D) || (obj.GetType().IsSubclassOf(typeof(ActionObject)) && !SceneManager.Instance.SceneStarted && GameManager.Instance.GetGameState() == GameStateEnum.SceneEditor) || obj.GetType() == typeof(APOrientation), $"{RENAME_BTN_LABEL}\n(selected object could not be renamed)"); CalibrationButton.SetInteractivity(obj.GetType() == typeof(Recalibrate) || obj.GetType() == typeof(CreateAnchor) || obj.GetType() == typeof(RecalibrateUsingServer), $"{CALIBRATION_BTN_LABEL}\n(selected object is not calibration cube)"); if (obj is Action3D action) { OpenMenuButton.SetInteractivity(action.Parameters.Count > 0, "Open action parameters menu\n(action has no parameters)"); } else { OpenMenuButton.SetInteractivity(obj.HasMenu(), $"{OPEN_MENU_BTN_LABEL}\n(selected object has no menu)"); } } }
private async void UpdateMoveAndRemoveBtns(string objId, Task <RequestResult> movable, Task <RequestResult> removable) { RequestResult move = await movable; RequestResult remove = await removable; if (selectedObject != null && objId != selectedObject.GetId()) // selected object was updated in the meantime { return; } MoveButton.SetInteractivity(move.Success, $"{MOVE_BTN_LABEL}\n({move.Message})"); MoveButton2.SetInteractivity(move.Success, $"{MOVE_BTN_LABEL}\n({move.Message})"); RemoveButton.SetInteractivity(remove.Success, $"{REMOVE_BTN_LABEL}\n({remove.Message})"); }