{"id":518,"date":"2010-02-07T12:59:35","date_gmt":"2010-02-07T11:59:35","guid":{"rendered":"http:\/\/www.feedingedge.co.uk\/blog\/?p=518"},"modified":"2010-02-07T12:59:35","modified_gmt":"2010-02-07T11:59:35","slug":"look-just-how-simple-things-can-be-unity3d-accessing-the-web","status":"publish","type":"post","link":"https:\/\/www.feedingedge.co.uk\/blog\/2010\/02\/07\/look-just-how-simple-things-can-be-unity3d-accessing-the-web\/","title":{"rendered":"Look just how simple things can be. Unity3d accessing the web"},"content":{"rendered":"\n<div class=\"twitter-share\"><a href=\"https:\/\/twitter.com\/intent\/tweet?via=epredator\" class=\"twitter-share-button\">Tweet<\/a><\/div>\n<p>I have been doing a lot of <a href=\"http:\/\/www.unity3d.com\">Unity3d <\/a>with data flying around, but I am still amazed at just how easy it is to get things to work.<br \/>\nFor the non-techies out there this should still make sense as its all drag and drop and a little bit of text.<br \/>\nSo you need a web based walk around some of your <a href=\"http:\/\/www.flickr.com\">flickr<\/a> pictures?<br \/>\nUnity3d makes it very easy to say &#8220;create scene&#8221;, &#8220;add terrain&#8221;, &#8220;add light&#8221;, &#8220;add first person walker (the thing that lets you move around&#8221; and finally to say &#8220;create cube&#8221;.<br \/>\nIt is as simple as any other package to create things, just like adding a graph in a spreadsheet, or rezzing cubes in Second Life.<br \/>\nOnce the Scene is created is it very easy to add a behaviour to an object in this case this script is types in and dragged and dropped onto each cube in the scene. (its in the help text too)<br \/>\n<code><br \/>\nvar url = \"http:\/\/farm3.static.flickr.com\/2656\/4250994754_6b071014d4_s.jpg\";<br \/>\nfunction Start () {<br \/>\n     \/\/ Start a download of the given URL<br \/>\n    var www : WWW = new WWW (url);<\/p>\n<p>    \/\/ Wait for download to complete<br \/>\n    yield www;<\/p>\n<p>    \/\/ assign texture<br \/>\n    renderer.material.mainTexture = www.texture;<br \/>\n}<\/code><\/p>\n<p>Basically you tell it a URL of an image, 3 lines of code later that image is on the surface of your object running live.<br \/>\nThe other thing that is easy to do is drag a predefined behaviour of &#8220;DragRigidBody&#8221; on the cube(s). Then you get the ability to move the cubes when they are running by holding onto them with the mouse and left click.<br \/>\n<a href=\"http:\/\/www.flickr.com\/photos\/epredator\/4336645171\/\" title=\"UnityScreenSnapz001 by epredator, on Flickr\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/farm3.static.flickr.com\/2745\/4336645171_b1f79a0153.jpg\" width=\"500\" height=\"372\" alt=\"UnityScreenSnapz001\" \/><\/a><br \/>\n<a href=\"http:\/\/www.flickr.com\/photos\/epredator\/4337390536\/\" title=\"UnityScreenSnapz003 by epredator, on Flickr\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/farm5.static.flickr.com\/4056\/4337390536_149dff8dee.jpg\" width=\"500\" height=\"372\" alt=\"UnityScreenSnapz003\" \/><\/a><\/p>\n<p>Now the other clever piece (for the techies and programmers amongst us) is that you can create an object of collection of objects and bring them out of the scene and create a &#8220;prefab&#8221;. This prefab means that you can create lots of live versions of an object in the scene. However if you need to change them, add a new behaviour etc you simply change the root prefab and the changes are inherited by all the prefabs in the scene. You are also able to override settings on each prefab.<br \/>\nSo I have a cube prefab, with the &#8220;Go get an image&#8221; script on it.<br \/>\nI drag a few of those into the scene and for each one I can individually set the URL they are going to use. All good Object Orientated stuff.<br \/>\nThis is not supposed to be a state of the art game :), but you can see how the drag and drop works and moving around using live images I drag in from my Flickr <a href=\"http:\/\/www.feedingedge.co.uk\/unity\/cubepics.html\">in this sample<\/a><br \/>\nClick in the view and W and A moves back and forwards, left click and hold the mouse over a block to move it around.<br \/>\nDownward gravity is reduced (just a number) and of course the URL&#8217;s could be entered live and change on the fly. I only used the square thumbnail URLs form my Flickr photos so they are not hi quality \ud83d\ude42<br \/>\nThis is also not a multiuser example (busy doing lots of that with Smartfox server at the moment) but it is just so accessible to be able to make and publish ideas.<br \/>\nThe code is less complicated that the HTML source of this page I would suggest. Its also free to do!<\/p>\n<iframe src=\"http:\/\/www.facebook.com\/plugins\/like.php?href=https%3A%2F%2Fwww.feedingedge.co.uk%2Fblog%2F2010%2F02%2F07%2Flook-just-how-simple-things-can-be-unity3d-accessing-the-web%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:450px; height:80px;\" allowTransparency=\"true\"><\/iframe><div name=\"googleone_share_1\" style=\"position:relative;z-index:5;float: right; margin-left: 10px;\"><g:plusone size=\"tall\" count=\"1\" href=\"https:\/\/www.feedingedge.co.uk\/blog\/2010\/02\/07\/look-just-how-simple-things-can-be-unity3d-accessing-the-web\/\"><\/g:plusone><\/div>","protected":false},"excerpt":{"rendered":"<p>I have been doing a lot of Unity3d with data flying around, but I am still amazed at just how easy it is to get things to work. For the non-techies out there this should still make sense as its all drag and drop and a little bit of text. So you need a web<br \/>\n            <span class=\"excerpt-readmore\"><a class=\"more-link\" href=\"https:\/\/www.feedingedge.co.uk\/blog\/2010\/02\/07\/look-just-how-simple-things-can-be-unity3d-accessing-the-web\/\"><\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,46],"tags":[414],"class_list":["post-518","post","type-post","status-publish","format-standard","hentry","category-metaverse","category-unity3d","tag-unity3d"],"_links":{"self":[{"href":"https:\/\/www.feedingedge.co.uk\/blog\/wp-json\/wp\/v2\/posts\/518","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.feedingedge.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.feedingedge.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.feedingedge.co.uk\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.feedingedge.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=518"}],"version-history":[{"count":2,"href":"https:\/\/www.feedingedge.co.uk\/blog\/wp-json\/wp\/v2\/posts\/518\/revisions"}],"predecessor-version":[{"id":520,"href":"https:\/\/www.feedingedge.co.uk\/blog\/wp-json\/wp\/v2\/posts\/518\/revisions\/520"}],"wp:attachment":[{"href":"https:\/\/www.feedingedge.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.feedingedge.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=518"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.feedingedge.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}