- Home /
Question by
sandeepraj · Mar 30, 2020 at 09:14 PM ·
vuforiaaugmented reality
Need help with with Vuforia Script
I am using the below Vuforia script but it has an error
Script Name: "Deploy Stage Once"
Error: Assets\Scripts\DeployStageOnce.cs(54,51): error CS1061: 'Anchor' does not contain a definition for 'transform' and no accessible extension method 'transform' accepting a first argument of type 'Anchor' could be found (are you missing a using directive or an assembly reference?)
using System; using UnityEngine; using Vuforia;
public class DeployStageOnce : MonoBehaviour { public GameObject AnchorStage; private PositionalDeviceTracker _deviceTracker; private GameObject _previousAnchor; public static string theRoute;
public void Start()
{
if (AnchorStage == null)
{
Debug.Log("AnchorStage must be specified");
return;
}
AnchorStage.SetActive(false);
}
public void Awake()
{
VuforiaARController.Instance.RegisterVuforiaStartedCallback(OnVuforiaStarted);
}
public void OnDestroy()
{
VuforiaARController.Instance.UnregisterVuforiaStartedCallback(OnVuforiaStarted);
}
private void OnVuforiaStarted()
{
_deviceTracker = TrackerManager.Instance.GetTracker<PositionalDeviceTracker>();
}
public void OnInteractiveHitTest(HitTestResult result)
{
if (result == null || AnchorStage == null)
{
Debug.LogWarning("Hit test is invalid or AnchorStage not set");
return;
}
var anchor = _deviceTracker.CreatePlaneAnchor(Guid.NewGuid().ToString(), result);
if (anchor != null)
{
AnchorStage.transform.parent = anchor.transform;
AnchorStage.transform.localPosition = Vector3.zero;
AnchorStage.transform.localRotation = Quaternion.identity;
AnchorStage.SetActive(true);
}
theRoute = "/" + anchor.name + "/" + AnchorStage.name;
if (_previousAnchor != null)
{
Destroy(_previousAnchor);
}
_previousAnchor = anchor;
}
}
Comment