Kinda
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
using UnityEngine.SceneManagement;
[RequireComponent (typeof (ARAnchorManager))]
[RequireComponent (typeof (ARRaycastManager))]
public class AnchorCreator : MonoBehaviour {
public Vector3 myVector;
public Quaternion myAngles;
public Pose hitPose;
public List s_Hits = new List ();
List m_Anchors;
ARRaycastManager m_RaycastManager;
ARAnchorManager m_AnchorManager;
public void RemoveAllAnchors () {
foreach (var anchor in m_Anchors) {
m_AnchorManager.RemoveAnchor (anchor);
}
m_Anchors.Clear ();
}
void Awake () {
m_RaycastManager = GetComponent ();
m_AnchorManager = GetComponent ();
m_Anchors = new List ();
myVector = new Vector3 (0.0f, 1.0f, 0.0f);
myAngles = Quaternion.Euler (0, 30, 0);
}
void Update () {
if (Input.touchCount == 0)
return;
var touch = Input.GetTouch (0);
if (touch.phase != TouchPhase.Began)
return;
if (m_RaycastManager.Raycast (touch.position, s_Hits, TrackableType.FeaturePoint)) {
// Raycast hits are sorted by distance, so the first one
// will be the closest hit.
// hitPose = s_Hits[0].pose;
// Debug.Log (“FIRST” + s_Hits[0].pose);
// s_Hits[0].pose = ((0.0, 0.5, 0.3), (0.0, 0.5, 0.3));
// Debug.Log (“SECOND” + s_Hits[0].pose);
// var anchor = m_AnchorManager.AddAnchor (hitPose);
}
}
public void AddElements () {
// hitPose = ((0.0f,0.0f,2.0f),(0.0f,0.0f,2.0f));
var anchor2 = m_AnchorManager.AddAnchor (hitPose);
if (anchor2 == null) {
Logger.Log (“Error creating anchor”);
} else {
m_Anchors.Add (anchor2);
}
}
public void ReloadScene () {
// hitPose = ((0.0f,0.0f,2.0f),(0.0f,0.0f,2.0f));
SceneManager.LoadScene(“Anchors”, LoadSceneMode.Single);
}
}