Home > Software engineering >  How to Play a Video in a Vuforia Image Target in Unity in 2022?
How to Play a Video in a Vuforia Image Target in Unity in 2022?

Time:10-06

How can I have a video play in a Vuforia Image target using Unity? The Vuforia core samples seem overly complicated.

I saw that they put a scrip in the previous answer but it doesn't work. Unfortunately times have changed and for example the OnTrakindFound and OnTrakindLost functions are not recognized by unity version 2021.3.10f1.I don't know if someone can help me with an updated script that works for me to link a video player to an image target and play it recently when the camera ar de vuforia me detect the image and I stay more or less like in this video: https://www.youtube.com/watch?v=izJatV5ypvM

CodePudding user response:

1.create a plane game object.

2.then add the component VideoPlayer to the plane.

3.drag your video to video clip.

4.create an image target.(for details how to do that check on vuforia website). https://library.vuforia.com/objects/create-and-load-targets-unity

5.make the plane child of the image target.

and now try it, if you want to play when find you can do it by script on the plane like that:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;

public class Test : MonoBehaviour
{
    VideoPlayer videoPlayer;
    private void Start()
    {
        videoPlayer = GetComponent<VideoPlayer>();
    }
    public void FindVideoPlayer(bool isFind)
    {
        if(isFind)
        {
            videoPlayer.Play();
        }
        else
        {
            videoPlayer.Stop();
        }
    }
}

and on the image target you have onFind and OnLost event, add the plane game object there and choose the FindVideoPlayer and set the bool true when found and false when lost. If it helped, please mark that I solved it, if not, I'd love to see the details so I can help

CodePudding user response:

Your script does not compile @Noam Riahi. I get mistake after mistake. You know why it can be. It throws me these three mistakes. The script does not work. Attached images:enter image description here

enter image description here

enter image description here

  • Related