我正在尝试编写代码,让玩家对箱子上的OnTriggerEvent2D做出反应,然后打开箱子清单。我这样做是为了在地图上随机生成箱子,并且清单位于场景中。
我尝试过将胸部库存移至现场和胸部预制件。 我将可交互代码添加到了预装箱中,并且当我在预装箱中放置了预备箱时,将预备箱作为游戏对象。当清单UI位于场景中时,我无法执行此操作。
using UnityEngine;
using UnityEngine.SceneManagement;
public class ChestInteractable : MonoBehaviour
{
[SerializeField] KeyCode interactableKey = KeyCode.E; //allow player to choose key
public GameObject chestInventoryUI;
private void OnTriggerEnter2D(Collider2D collision) //if player collides with chest (I am unsure if OnCollisionEnter2D is better, I am only a beginner)
{
if(Input.GetKeyDown(interactableKey)) {
chestInventoryUI.SetActive(true); //open up chest inventory
Time.timeScale = 0f; //time is stopped
}
if(Input.GetKeyUp(interactableKey))
{
chestInventoryUI.SetActive(false); //closes chest inventory
Time.timeScale = 1f; //time resumes
}
}
}
我希望箱子清单UI可见,游戏可以停止,但是什么也没发生。
答案 0 :(得分:0)
SEELCT STUFF(Email, CHARINDEX('.com', Email, 1) + LEN('.com'), LEN(Email), '') AS Email
FROM TableName