PrivateModeEventObject.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using UnityEngine;
  3. public class PrivateModeEventObject : MonoBehaviour
  4. {
  5. public int GetEventNo()
  6. {
  7. return this.eventNo;
  8. }
  9. public void CreateNewStar()
  10. {
  11. GameObject childObject = UTY.GetChildObject(base.gameObject, "top", true);
  12. if (childObject == null)
  13. {
  14. childObject = UTY.GetChildObject(base.gameObject, "Top", false);
  15. }
  16. GameObject gameObject = UnityEngine.Object.Instantiate(Resources.Load("ScenePrivate/Odogu_gp002_SymbolStar")) as GameObject;
  17. gameObject.transform.SetParent(childObject.transform, false);
  18. }
  19. private void Update()
  20. {
  21. if (GameMain.Instance.VRMode || !NInput.GetMouseButtonDown(0))
  22. {
  23. return;
  24. }
  25. if (UICamera.Raycast(Input.mousePosition))
  26. {
  27. return;
  28. }
  29. Ray ray = GameMain.Instance.MainCamera.camera.ScreenPointToRay(Input.mousePosition);
  30. RaycastHit raycastHit = default(RaycastHit);
  31. if (!Physics.Raycast(ray, out raycastHit, float.PositiveInfinity, LayerMask.GetMask(new string[]
  32. {
  33. LayerMask.LayerToName(base.gameObject.layer)
  34. })) || raycastHit.transform != base.transform)
  35. {
  36. return;
  37. }
  38. if (PrivateModeEventObject.onClickObject != null)
  39. {
  40. PrivateModeEventObject.onClickObject(this.eventNo);
  41. }
  42. }
  43. private void OnTriggerEnter(Collider collider)
  44. {
  45. if (GameMain.Instance.VRMode && collider.gameObject.layer == LayerMask.NameToLayer("OvrGrabHand") && PrivateModeEventObject.onClickObject != null)
  46. {
  47. PrivateModeEventObject.onClickObject(this.eventNo);
  48. }
  49. }
  50. [SerializeField]
  51. [Header("イベント番号")]
  52. private int eventNo;
  53. public static Action<int> onClickObject;
  54. }