選擇vuforia資料夾 > Scripts > DefaultTrackableEventHandler
加入黃框內的程式碼
using HtmlAgilityPack; using System.Net; using System.IO; string url = "http://www.just-the-word.com/main.pl?word=hello"; string xpath = "/html[1]/body[1]/div[1]/div[3]/div[1]"; //xpath是使用HAPXPathFinder v0.9軟體來尋找出來的 HttpWebRequest httpWebRequest = WebRequest.Create(url) as HttpWebRequest; try { HttpWebResponse httpWebResponse = httpWebRequest.GetResponse() as HttpWebResponse; Stream stream = httpWebResponse.GetResponseStream(); StreamReader reader = new StreamReader(stream, Encoding.UTF8); string s = reader.ReadToEnd(); reader.Close(); stream.Close(); httpWebResponse.Close(); HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(s); //16GB 32GB 64GB 的運送時間XPATH HtmlNode anchors = htmlDoc.DocumentNode.SelectSingleNode(xpath); //HtmlNode anchors32 = htmlDoc.DocumentNode.SelectSingleNode("/html/body/div[2]/div[3]/div/div[2]/div[2]/div[3]/ul/li[2]/label/span/span[3]/span"); //HtmlNode anchors64 = htmlDoc.DocumentNode.SelectSingleNode("/html/body/div[2]/div[3]/div/div[2]/div[2]/div[3]/ul/li[3]/label/span/span[3]/span"); //output //set RichTextBox richTextBox.Document.Blocks.Add(new Paragraph(new Run(anchors.InnerText))); //get RichTextBox //string richText = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd).Text; } catch (WebException web) { //error message }
private void OnTrackingLost() //當目標物遺失就執行這方法 { Renderer[] rendererComponents = GetComponentsInChildren(true); Collider[] colliderComponents = GetComponentsInChildren (true); /* // Disable rendering: foreach (Renderer component in rendererComponents) { component.enabled = false; //把false改成true,當目標物遺失虛擬物件不會跟著消失 } // Disable colliders: foreach (Collider component in colliderComponents) { component.enabled = false; //把false改成true,當目標物遺失虛擬物件不會跟著消失 } */ Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost"); }