{"id":1104,"date":"2017-12-25T20:08:51","date_gmt":"2017-12-25T19:08:51","guid":{"rendered":"http:\/\/jmladeno.net\/?page_id=1104"},"modified":"2018-05-06T15:31:43","modified_gmt":"2018-05-06T13:31:43","slug":"example-to-send-lsl-streams-in-unity-for-htc-vive","status":"publish","type":"page","link":"https:\/\/jmladeno.net\/index.php\/example-to-send-lsl-streams-in-unity-for-htc-vive\/","title":{"rendered":"Example to send LSL streams in Unity for HTC Vive"},"content":{"rendered":"<p><em> <strong>Stream continuous data from Unity for HTC Vive<\/strong><\/em><br \/>\n(position, rotation etc.)<br \/>\nTested on Windows machines only<\/p>\n<p>Enter Unity, open your project (example used here &#8212; <a href=\"https:\/\/www.raywenderlich.com\/149239\/htc-vive-tutorial-unity\" target=\"_blank\" rel=\"noopener noreferrer\">htc-vive-tutorial-unity<\/a>) and :<\/p>\n<p>1. enter the Scripts folder from the LSL4Unity folder, to access LSL OutletsSR script;<br \/>\n<em>(it is my modification of the original script &#8211; I only added the possibility to choose a Sampling Rate &#8212; between Fixed\/Late Update and Update)<\/em><br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/Capture2-1024x563.png\" alt=\"\" width=\"1024\" height=\"563\" class=\"alignleft size-large wp-image-900\" srcset=\"https:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/Capture2-1024x563.png 1024w, https:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/Capture2-300x165.png 300w, https:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/Capture2-768x423.png 768w, https:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/Capture2.png 1325w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>2. attach (drag and drop) this script to each game object of interest<br \/>\n(in my case, I like to stream the position of the ball &#8212; Player)<br \/>\n<div id='gallery-1' class='gallery galleryid-1104 gallery-columns-2 gallery-size-medium'><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon portrait'>\n\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"281\" height=\"300\" src=\"https:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/Capture8-281x300.png\" class=\"attachment-medium size-medium\" alt=\"\" aria-describedby=\"gallery-1-922\" srcset=\"https:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/Capture8-281x300.png 281w, https:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/Capture8.png 508w\" sizes=\"auto, (max-width: 281px) 100vw, 281px\" \/>\n\t\t\t<\/div>\n\t\t\t\t<figcaption class='wp-caption-text gallery-caption' id='gallery-1-922'>\n\t\t\t\tDrag and Drop script to your gameObject\n\t\t\t\t<\/figcaption><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon portrait'>\n\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"207\" height=\"300\" src=\"https:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/playerDrag-207x300.png\" class=\"attachment-medium size-medium\" alt=\"\" aria-describedby=\"gallery-1-1074\" srcset=\"https:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/playerDrag-207x300.png 207w, https:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/playerDrag.png 686w\" sizes=\"auto, (max-width: 207px) 100vw, 207px\" \/>\n\t\t\t<\/div>\n\t\t\t\t<figcaption class='wp-caption-text gallery-caption' id='gallery-1-1074'>\n\t\t\t\tPlayer with LSLTransformSR script\n\t\t\t\t<\/figcaption><\/figure>\n\t\t<\/div>\n<\/p>\n<p>3. When clicking on your gameObj (Player), look at the Inspector,<br \/>\nand add in the Sample Source box the object you wish to stream data from,<br \/>\nby clicking on the circle on the right.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/InspectorPlayer1-1024x541.jpg\" alt=\"\" width=\"1024\" height=\"541\" class=\"alignleft size-large wp-image-1082\" srcset=\"https:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/InspectorPlayer1-1024x541.jpg 1024w, https:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/InspectorPlayer1-300x159.jpg 300w, https:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/InspectorPlayer1-768x406.jpg 768w, https:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/InspectorPlayer1-1440x761.jpg 1440w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>4. As I want to stream the <em>position<\/em> of my Player (the ball)  and send the stream with a <em>Fixed<\/em> Sampling Rate (so don&#8217;t forget to put <em>Fixed Update<\/em>). <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/InspectorPlayer2-199x300.png\" alt=\"\" width=\"199\" height=\"300\" class=\"alignleft size-medium wp-image-1083\" srcset=\"https:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/InspectorPlayer2-199x300.png 199w, https:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/InspectorPlayer2-681x1024.png 681w, https:\/\/jmladeno.net\/wp-content\/uploads\/2017\/12\/InspectorPlayer2.png 686w\" sizes=\"auto, (max-width: 199px) 100vw, 199px\" \/><br \/>\n(I need only to check the position box from the three possible check-boxes)<br \/>\nAlso don&#8217;t forget to give a name and type to your streams.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Stream continuous data from Unity for HTC Vive (position, rotation etc.) Tested on Windows machines only Enter Unity, &hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1104","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/pages\/1104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/comments?post=1104"}],"version-history":[{"count":2,"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/pages\/1104\/revisions"}],"predecessor-version":[{"id":1218,"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/pages\/1104\/revisions\/1218"}],"wp:attachment":[{"href":"https:\/\/jmladeno.net\/index.php\/wp-json\/wp\/v2\/media?parent=1104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}