Hi. I want to draw line on AR World’s Floor. So first, I use AR raycast and draw the floor. I Check the floor area is fill the Plane’s Mesh. And I make a Cube that touch on plane mesh area. So I think floor’s area is similar real world’s floor. But I can not get the floor’s Coordinate. How can i get the mesh area’s Coordinate?
Here is a Code when i make a cube when touch on mesh area and app’s screenshot.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
public class FloorEvent : MonoBehaviour
{
public GameObject prefabToPlace;
public ARRaycastManager aRSessionOrigin;
public List<ARRaycastHit> hits;
void Start()
{
hits = new List<ARRaycastHit>();
aRSessionOrigin = GetComponent<ARRaycastManager>();
}
void Update()
{
if (Input.touchCount > 0)
{
for (int i=0; i < Input.touchCount; i++)
{
Touch touch = Input.GetTouch(i);
if (touch.phase == TouchPhase.Began)
{
if (aRSessionOrigin.Raycast(touch.position, hits))
{
Pose hitPose = hits[0].pose;
Instantiate(prefabToPlace, hitPose.position, hitPose.rotation);
Debug.Log("1 : "+hitPose.position);
}
}
}
}
}
}