Log in or register to post comments

new vuforia version

May 3, 2021 - 9:45pm #1

my friend has created a code for me to create an AR app using vuforia in unity which was working completely ok. now I install new unity with the new version of vuforia it shows some error I find out some changes were applied like "MonoBehaviour, ITrackableEventHandler" is changed to "DefaultTrackableEventHandler" but I have some error which cant understand

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using Vuforia;

using System;

using System.Text;

using System.Net;

using System.Net.Sockets;

using System.Threading;

public class Shutter0 : DefaultTrackableEventHandler

{

    TrackableBehaviour mTrackableBehaviour;

    GameObject derakht;

    string IP;

    public int port;

    GameObject TextMesh;

    public string myText;

    // "connection" things

    IPEndPoint remoteEndPoint;

    UdpClient client;

    // Start is called before the first frame update

    void Start()

    {

        derakht = GameObject.Find("derakht");

        mTrackableBehaviour = GetComponent<TrackableBehaviour>();

        if (mTrackableBehaviour)

        {

            mTrackableBehaviour.RegisterTrackableEventHandler(this);

        }

        //OnTrackingLost();

        IP = "127.0.0.1";

        port = 8050;

        string myText = "25j";

        remoteEndPoint = new IPEndPoint(IPAddress.Parse(IP), port);

        client = new UdpClient();

        // status

        print("Sending to " + IP + " : " + port);

    }

    // Implementation of the ITrackableEventHandler function called when the

    // tracking state changes.

    public void OnTrackableStateChanged(

     TrackableBehaviour.Status previousStatus,

     TrackableBehaviour.Status newStatus)

    {

        if (newStatus == TrackableBehaviour.Status.DETECTED ||

            newStatus == TrackableBehaviour.Status.TRACKED)

        {

            OnTrackingFound();

        }

    }

    private void OnTrackingFound()

    {

        try

        {

            // encode string to UTF8-coded bytes

            myText = "0";

            byte[] data = Encoding.UTF8.GetBytes(myText);

            // send the data

            client.Send(data, data.Length, remoteEndPoint);

        }

        catch (Exception err)

        {

            print(err.ToString());

        }

    }

}

 

new vuforia version

May 4, 2021 - 1:24am #2

Hi

Please review our migration guide: http://library.vuforia.com/articles/Solution/How-To-Migrate-a-Unity-Project.html

Thank you.

Vuforia Engine Support

Log in or register to post comments