53 lines
1.1 KiB
C#
53 lines
1.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
public class Sign : MonoBehaviour
|
|
{
|
|
public GameObject signSprite;
|
|
private bool canPress;//´ò¿ª
|
|
|
|
public Transform playerTrans;
|
|
private PlayerInputControl playerInput;
|
|
|
|
private IInteractiable targetItem;
|
|
private void Update()
|
|
{
|
|
signSprite.SetActive(canPress);
|
|
signSprite.transform.localScale = playerTrans.localScale;
|
|
|
|
// playerInput = new PlayerInputControl();
|
|
// playerInput.Enable();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
//playerInput.GamePlayerInput.Confirm.started += OnConfirm;
|
|
}
|
|
|
|
private void OnConfirm(InputAction.CallbackContext context)
|
|
{
|
|
if(canPress)
|
|
{
|
|
targetItem.TriggerAction();
|
|
}
|
|
}
|
|
|
|
private void OnTriggerStay2D(Collider2D collision)
|
|
{
|
|
if (collision.CompareTag("Interactable"))
|
|
{
|
|
canPress = true;
|
|
targetItem = collision.GetComponent<IInteractiable>();
|
|
}
|
|
}
|
|
|
|
|
|
private void OnTriggerExit2D(Collider2D collision)
|
|
{
|
|
canPress = false;
|
|
}
|
|
}
|