Hello!
I have 2 ImageTarget. and There're 2 Images(UI). I want them varied depending on ImageTarget.(qrcode and intelcore7)
I did so, but sprite doesn't work. How fix it?
img1.sprite = Resources.Load<Sprite>("2");
It's my all code
using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic;
namespace Vuforia { public class DataTarget : MonoBehaviour {
public GameObject layout; public Transform Header; public Image img1, img2; //// <<<<<<<<<<<<<<<<<<< public Transform info, About;void Update() { // StateManager sm = TrackerManager.Instance.GetStateManager(); IEnumerable<TrackableBehaviour> tbs = sm.GetActiveTrackableBehaviours();
foreach (TrackableBehaviour tb in tbs) { string name = tb.TrackableName; ImageTarget it = tb.Trackable as ImageTarget; Vector2 size = it.GetSize();Debug.Log("Active image target:" + name + " -size: " + size.x + ", " + size.y); Header.GetComponent<Text>().text = name; // if (name == "qrcode") { // img1.sprite = Resources.Load<Sprite>("2"); <<<<<<<<<<<<<<<<<<<<<<<<<< Header.GetComponent<Text>().text = "Dell PowerEdge R630 210-ACXS-124_K2"; info.GetComponent<Text>().text = "info text"; About.GetComponent<Text>().text = "Text about"; }
if (name == "intelcore7") { Header.GetComponent<Text>().text = " Intel Core i7 7700K OEM"; About.GetComponent<Text>().text = "About info."; info.GetComponent<Text>().text = "text info";} }
}} }