Hello there, I'm a total beginner of Unity and scripting at all. So please excuse me when the solution to this is very simple and I'm just too dumb to find it. I have an AR Project, where you can place one object and size, rotate, color it whatever you like. Just a little gimmick, but a big problem here for me. I was following this tutorial: I wrote the code on PlaceOnPlane.cs, expecting it to work. But it just spits out two errors. Everything else works, but not this. I'm using Unity 2019.1.9f1 Personal. Errors: Error CS0234: The type or namespace name 'PlaneWithinPolygon' does not exist in the namespace 'UnityEngine.Experimental.XR' (are you missing an assembly reference?) (CS0234) (Assembly-CSharp) Error CS1061: 'ARSessionOrigin' does not contain a definition for 'Raycast' and no accessible extension method 'Raycast' accepting a first argument of type 'ARSessionOrigin' could be found (are you missing a using directive or an assembly reference?) (CS1061) (Assembly-CSharp) Here's my code where the error is: Code (CSharp): void Update() { if (Input.touchCount == 0) return; Touch touch = Input.GetTouch(0); // errors right here if (sessionOrigin.Raycast(touch.position, hits, UnityEngine.Experimental.XR.PlaneWithinPolygon) && IsPointerOverUIObject(touch.position)) { Pose pose = hits[0].pose; if(!model.activeInHierarchy) { model.SetActive(true); model.transform.position = pose.position; model.transform.rotation = pose.rotation; } else { model.transform.position = pose.forward; } } } So, I hope someone could help me with this. Thanks!
Hi, from what I've seen (sorry havent read it all your post and none of that video), but in your code, you need to have something like this : Code (CSharp): protected ARRaycastManager m_RaycastManager; void Awake() { m_RaycastManager = GetComponent<ARRaycastManager>(); } void Update() { if (Input.touchCount == 0) return; Touch touch = Input.GetTouch(0); // errors right here if (m_RaycastManager.Raycast(touch.position, hits, UnityEngine.Experimental.XR.PlaneWithinPolygon) && IsPointerOverUIObject(touch.position)) { Pose pose = hits[0].pose; if (!model.activeInHierarchy) { model.SetActive(true); model.transform.position = pose.position; model.transform.rotation = pose.rotation; } else { model.transform.position = pose.forward; } } } You need to have a ARRaycastManager component on the AR session origin, and then use that for your ray casting. hope this gets you closer. plus never tested that code, but note-padded it.
@lloydhooson Alright, thanks, this helped a lot! Now there's only one error (PlaneWithinPolygon) left.