I made an empty object and called it “Placement Indicator”, I added a plane to its children, then I added ARRayCastManager to my “AR Session Origin” in the project. I wrote this C# script :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
public class PlacementIndicator : MonoBehaviour
{
private ARRaycastManager RayManager;
private GameObject target;
// Start is called before the first frame update
void Start()
{
RayManager = FindObjectOfType<ARRaycastManager>();
target = transform.GetChild(0).gameObject;
target.SetActive(false);
}
// Update is called once per frame
void Update()
{
List<ARRaycastHit> hits = new List<ARRaycastHit>();
RayManager.Raycast(new Vector2(Screen.width / 2, Screen.height / 2), hits, TrackableType.Planes);
if(hits.Count > 0)
{
transform.position = hits[0].pose.position;
transform.rotation = hits[0].pose.rotation;
if (!target.activeInHierarchy)
target.SetActive(true);
}
}
}
And then, when I run the app on my phone, there is no placement indicator (and I’m sure it hits planes, as I tested with Plane Manager).
What are the possibilities of this “malfunctioning” here?