using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; using Vuforia; public class onlinetargets : MonoBehaviour { // Start is called before the first frame update void Start() { StartCoroutine(CreateImageTargetFromDownloadedTexture()); } IEnumerator CreateImageTargetFromDownloadedTexture() { using (UnityWebRequest uwr = UnityWebRequestTexture.GetTexture("https://takhte-sefid.ir/myimage.jpg")) { yield return uwr.SendWebRequest(); if (uwr.isNetworkError || uwr.isHttpError) { Debug.Log(uwr.error); } else { var objectTracker = TrackerManager.Instance.GetTracker(); // Get downloaded texture once the web request completes var texture = DownloadHandlerTexture.GetContent(uwr); // get the runtime image source and set the texture var runtimeImageSource = objectTracker.RuntimeImageSource; runtimeImageSource.SetImage(texture, 0.15f, "onlinetarget"); // create a new dataset and use the source to create a new trackable var dataset = objectTracker.CreateDataSet(); var trackableBehaviour = dataset.CreateTrackable(runtimeImageSource, "onlinetarget"); // add the DefaultTrackableEventHandler to the newly created game object trackableBehaviour.gameObject.AddComponent(); // activate the dataset objectTracker.ActivateDataSet(dataset); // TODO: add virtual content as child object(s) } } } // Update is called once per frame void Update() { } }