public void Show(BuildableWorldObject invoker, UnityAction[] actions) { if (actions == null) { return; } Hide(); Target = invoker; if (canvas.worldCamera == null) { canvas.worldCamera = PlayerNetwork.LocalPlayer?.GetComponent <PlayerCameraController>()?.CameraReference; } if (actions.Length > interactionButtons.Count) { Debug.LogWarning("[BuildableInteractionMenu] More actions than interaction buttons."); } for (int i = 0; i < interactionButtons.Count; i++) { if (i >= actions.Length) { break; } interactionButtons[i].gameObject.SetActive(true); interactionButtons[i].onClick.AddListener(actions[i]); } gameObject.SetActive(true); }
public void Hide() { Target = null; foreach (Button button in interactionButtons) { button.onClick.RemoveAllListeners(); button.gameObject.SetActive(false); } gameObject.SetActive(false); }