public void PopulateInteractionMenu(Interactable i) { // If this is run with i set to null, this means there is nothing to interact with. if (i == null) { interactWindow.gameObject.SetActive(false); return; } interactWindow.gameObject.SetActive(true); interactObjectName.text = i.name; if (i.InProgress == true) { interactInstruction.text = i.inProgressMessage; interactButtonPrompt.sprite = inProgress; } else if (i.CanPlayerInteract(player) == false) { interactInstruction.text = i.deniedMessage; interactButtonPrompt.sprite = denied; } else { interactInstruction.text = i.instructionMessage; interactButtonPrompt.sprite = interactable; } }
// Update is called once per frame void Update() { Interactable i = LookingAt(); // Update the tooltip window based off if the player is looking at something interactable playerHandler.hud.PopulateInteractionMenu(i); // If the player presses the interact button // If the player can currently interact with the object // If the object is not cooling down or in the middle of performing an action if (i != null && Input.GetButtonDown("Interact") && i.CanPlayerInteract(playerHandler) == true && i.InProgress == false) { i.OnInteract(playerHandler); } }