2021년 4학년 1학기 기업연계프로젝트2 컴퓨터소프트웨어공학과 <원광투어팀> 팀장 : 송유진 팀원 : 김나영, 이경희, 한유진
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.4 KiB

5 years ago
  1. //========= Copyright 2016-2020, HTC Corporation. All rights reserved. ===========
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. namespace HTC.UnityPlugin.Pointer3D
  6. {
  7. public class Physics2DRaycastMethod : PhysicsRaycastMethod
  8. {
  9. private static readonly RaycastHit2D[] hits = new RaycastHit2D[64];
  10. public override void Raycast(Ray ray, float distance, List<RaycastResult> raycastResults)
  11. {
  12. var hitCount = Physics2D.GetRayIntersectionNonAlloc(ray, hits, distance, RaycastMask);
  13. for (int i = 0; i < hitCount; ++i)
  14. {
  15. var sr = hits[i].collider.gameObject.GetComponent<SpriteRenderer>();
  16. raycastResults.Add(new RaycastResult
  17. {
  18. gameObject = hits[i].collider.gameObject,
  19. module = raycaster,
  20. distance = Vector3.Distance(ray.origin, hits[i].transform.position),
  21. worldPosition = hits[i].point,
  22. worldNormal = hits[i].normal,
  23. screenPosition = Pointer3DInputModule.ScreenCenterPoint,
  24. index = raycastResults.Count,
  25. sortingLayer = sr != null ? sr.sortingLayerID : 0,
  26. sortingOrder = sr != null ? sr.sortingOrder : 0
  27. });
  28. }
  29. }
  30. }
  31. }