PrivateModeEventObject.cs 881 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using UnityEngine;
  3. public class PrivateModeEventObject : MonoBehaviour
  4. {
  5. public int GetEventNo()
  6. {
  7. return this.eventNo;
  8. }
  9. private void Update()
  10. {
  11. if (!NInput.GetMouseButtonDown(0))
  12. {
  13. return;
  14. }
  15. if (UICamera.Raycast(Input.mousePosition))
  16. {
  17. return;
  18. }
  19. Ray ray = GameMain.Instance.MainCamera.camera.ScreenPointToRay(Input.mousePosition);
  20. RaycastHit raycastHit = default(RaycastHit);
  21. if (!Physics.Raycast(ray, out raycastHit, float.PositiveInfinity, LayerMask.GetMask(new string[]
  22. {
  23. LayerMask.LayerToName(base.gameObject.layer)
  24. })) || raycastHit.transform != base.transform)
  25. {
  26. return;
  27. }
  28. if (PrivateModeEventObject.onClickObject != null)
  29. {
  30. PrivateModeEventObject.onClickObject(this.eventNo);
  31. }
  32. }
  33. [SerializeField]
  34. [Header("イベント番号")]
  35. private int eventNo;
  36. public static Action<int> onClickObject;
  37. }