Here is my code for QR code tracking. Using a gitHub example and added a new function named 'Launch' as
public void Launch(string uri)
When I call it later, it gives:
The name 'Launch' does not exist in this current context
Is my declaration wrong or should I include in the 'QRTracking' function? Using, Unity 2019.4.14f1, Visual Studio 2019, UWP platform. Have deleted some parts of the code with '...' to reduce the size that I thought was not relevant. Any tips would be very helpful. I am quite new in C#.
using System.Collections;
using System;
using System.Collections.Generic;
using UnityEngine;
#if WINDOWS_UWP
using Windows.Perception.Spatial;
public void Launch (string uri)
{
Debug.Log($"LaunchUri: Launching {uri}"); #if WINDOWS_UWP
UnityEngine.WSA.Application.InvokeOnUIThread(async () =>
{
bool result = await global::Windows.System.Launcher.LaunchUriAsync(new
System.Uri(uri));
if (!result)
{
Debug.LogError("Launching URI failed to launch.");
}
}, false); #else
Application.OpenURL(uri);
#endif
}
#endif
namespace QRTracking
{
[RequireComponent(typeof(QRTracking.SpatialGraphCoordinateSystem))]
public class QRCode : MonoBehaviour
{
public Microsoft.MixedReality.QR.QRCode qrCode;
private GameObject qrCodeCube;
....
....
private bool launch = false;
private System.Uri uriResult;
private long lastTimeStamp = 0;
// Use this for initialization
void Start()
{
PhysicalSize = 0.1f;
CodeText = "Dummy";
if (qrCode == null)
{
throw new System.Exception("QR Code Empty");
}
PhysicalSize = qrCode.PhysicalSideLength;
CodeText = qrCode.Data;
....
....
QRID.text = "Id:" + qrCode.Id.ToString();
QRNodeID.text = "NodeId:" + qrCode.SpatialGraphNodeId.ToString();
QRText.text = CodeText;
if (System.Uri.TryCreate(CodeText, System.UriKind.Absolute,out uriResult))
{
validURI = true;
QRText.color = Color.blue;
}
...
...
Debug.Log("Id= " + qrCode.Id + "NodeId= " + qrCode.SpatialGraphNodeId + " PhysicalSize
= " + PhysicalSize + " TimeStamp = " + qrCode.SystemRelativeLastDetectedTime.Ticks + "
QRVersion = " + qrCode.Version + " QRData = " + CodeText);
// added here
Debug.Log("Call Launch");
Launch("http://" + CodeText"); // -> error: Name 'Launch' does not exist in the
current context
}
.....
.....