public void Start() { ItemSynthesizer.Initialize(); // create the texture for bounding boxes mBoundingBoxTexture = new Texture2D(1, 1, TextureFormat.ARGB32, false); mBoundingBoxTexture.SetPixel(0, 0, mBBoxColor); mBoundingBoxTexture.Apply(false); mBoundingBoxMaterial = new Material(boundingBoxMaterial); mBoundingBoxMaterial.SetTexture("_MainTex", mBoundingBoxTexture); // register to TextReco events var trBehaviour = GetComponent <TextRecoBehaviour>(); if (trBehaviour) { trBehaviour.RegisterTextRecoEventHandler(this); } // register for the OnVideoBackgroundConfigChanged event at the VuforiaBehaviour VuforiaBehaviour vuforiaBehaviour = FindObjectOfType <VuforiaBehaviour>(); if (vuforiaBehaviour) { vuforiaBehaviour.RegisterVideoBgEventHandler(this); } //mDisplayedWords = textRecoCanvas ? textRecoCanvas.GetComponentsInChildren<Text>(true) : new Text[0]; }
void Update() { if (mIsInitialized) { // Once the text tracker has initialized and every time the video background changed, // set the region of interest if (mVideoBackgroundChanged) { TextTracker textTracker = TrackerManager.Instance.GetTracker <TextTracker>(); if (textTracker != null) { CalculateLoupeRegion(); textTracker.SetRegionOfInterest(mDetectionAndTrackingRect, mDetectionAndTrackingRect); } mVideoBackgroundChanged = false; } // Clear the content of the displayed words /*foreach (var dw in mDisplayedWords) * { * dw.text = ""; * }*/ // Update the list of words displayed mSortedWords.RemoveAll(p => string.IsNullOrEmpty(p.Word.StringValue)); for (int i = 0; i < mSortedWords.Count; i++) { var word = mSortedWords[i]; if (word.Word != null && !string.IsNullOrEmpty(word.Word.StringValue) && itemId != word.Word.StringValue) { itemId = word.Word.StringValue; lastSeenItem = ItemSynthesizer.Synthesize(itemId); UnityEngine.UI.Image buttonImage = GameObject.Find("ButtonImage").GetComponent <UnityEngine.UI.Image>(); if (lastSeenItem != null) { //mDisplayedWords[0].text = lastSeenItem.id; Debug.Log(lastSeenItem); if (buttonImage != null) { buttonImage.sprite = inventoryHandler.m_icons.Find(sprite => sprite.name.Equals(lastSeenItem.id)); questManager.SetLastSeenImage(buttonImage); questManager.SetLastSeenItem(lastSeenItem.id); } } } } if (mSortedWords.Count == 0) { UnityEngine.UI.Image buttonImage = GameObject.Find("ButtonImage").GetComponent <UnityEngine.UI.Image>(); buttonImage.sprite = inventoryHandler.m_icons.Find(sprite => sprite.name == "empty"); } } }