Skip to content

Instantly share code, notes, and snippets.

Last active Jun 20, 2019
What would you like to do?
AR Foundation create object
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
public class SpawnObject : MonoBehaviour {
private ARSessionOrigin origin;
private List<ARRaycastHit> hitResults = new List<ARRaycastHit>();
[SerializeField] GameObject prefab;
private void Awake()
origin = GetComponent<ARSessionOrigin>();
void Update ()
if( origin.Raycast(Input.GetTouch(0).position, hitResults))
Instantiate(prefab, hitResults[0].pose.position, Quaternion.identity);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment