{"id":3793,"date":"2015-04-23T01:42:36","date_gmt":"2015-04-22T22:42:36","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=3793"},"modified":"2015-04-24T23:37:30","modified_gmt":"2015-04-24T20:37:30","slug":"webgl-build-custom-loading-effect","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2015\/04\/23\/webgl-build-custom-loading-effect\/","title":{"rendered":"WebGL Build &#8211; Custom Loading Effect"},"content":{"rendered":"<p><a href=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/webgl_loader_effect.gif\" target=\"_blank\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3795\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2015\/04\/23\/webgl-build-custom-loading-effect\/webgl_loader_effect\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/webgl_loader_effect.gif?fit=680%2C431&amp;ssl=1\" data-orig-size=\"680,431\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"webgl_loader_effect\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/webgl_loader_effect.gif?fit=300%2C190&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/webgl_loader_effect.gif?fit=680%2C431&amp;ssl=1\" class=\"alignnone size-full wp-image-3795\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/webgl_loader_effect.gif?resize=680%2C431\" alt=\"webgl_loader_effect\" width=\"680\" height=\"431\" \/><\/a><\/p>\n<p>Webgl build progress meter seems stuck at the end sometimes,<br \/>\nso it would be nice to have some &#8220;loading\/uncompressing&#8221; effect there..<\/p>\n<p><strong>WebGL example:<\/strong><br \/>\n<a title=\"http:\/\/unitycoder.com\/upload\/demos\/CustomWebGLLoader\/\" href=\"http:\/\/unitycoder.com\/upload\/demos\/CustomWebGLLoader\/\" target=\"_blank\">http:\/\/unitycoder.com\/upload\/demos\/CustomWebGLLoader\/<\/a> *its <a title=\"http:\/\/ludumdare.com\/compo\/ludum-dare-32\/?action=preview&amp;uid=27533\" href=\"http:\/\/ludumdare.com\/compo\/ludum-dare-32\/?action=preview&amp;uid=27533\" target=\"_blank\"><em>copy of my LudumDare32 entry<\/em><\/a><\/p>\n<p>&#8211; Caching seems to cause some problems though, effect starts too early or too late?<br \/>\n&#8211; Probably need to use some background worker, as it hangs on the final step..? (or use CSS animations, they are in separate thread?)<br \/>\n&#8211; Could make it as a ready template, so no need to edit code after publish<br \/>\n&#8211; Using animated gif as background instead would be better, no need javascript timers<\/p>\n<p>Steps for adding the effect to webgl build: <em>(^or check source of that webgl page)<\/em><\/p>\n<p>&nbsp;<\/p>\n<p><strong>\/\/ OPEN FILE<\/strong><br \/>\nindex.html<\/p>\n<p><strong>\/\/ FIND LINES<\/strong><br \/>\n&lt;p class=&#8221;footer&#8221;&gt;&amp;laquo; created with &lt;a href=&#8221;http:\/\/unity3d.com\/&#8221; title=&#8221;Go to unity3d.com&#8221;&gt;Unity&lt;\/a&gt; &amp;raquo;&lt;\/p&gt;<br \/>\n&lt;script type=&#8217;text\/javascript&#8217;&gt;<\/p>\n<p><strong>\/\/ INSERT AFTER THOSE LINES<\/strong><br \/>\nvar bgTimer=null;<br \/>\nvar originalBgColor = document.getElementsByTagName(&#8220;body&#8221;)[0].style.backgroundColor;<br \/>\nfunction LoaderEffect() {<br \/>\ndocument.getElementsByTagName(&#8220;body&#8221;)[0].style.backgroundColor = &#8220;#&#8221; + (Math.round(Math.random() * 0XFFFFFF)).toString(16);<br \/>\n}<br \/>\nfunction StopLoaderEffect()<br \/>\n{<br \/>\nwindow.clearInterval(bgTimer);<br \/>\ndocument.getElementsByTagName(&#8220;body&#8221;)[0].style.backgroundColor = originalBgColor;<br \/>\n}<\/p>\n<p><strong>\/\/ FIND LINE<\/strong><br \/>\nreturn function(text) {<\/p>\n<p><strong>\/\/ INSERT AFTER THAT LINE<\/strong><br \/>\nif (text.indexOf(&#8220;Creating OpenGLES2.0 graphics device&#8221;)&gt;-1) StopLoaderEffect();<\/p>\n<p><strong>\/\/ FIND LINE<\/strong><br \/>\nprintErr: function(text) {<\/p>\n<p><strong>\/\/ INSERT AFTER THAT LINE<\/strong><br \/>\nif (text == &#8220;run() called, but dependencies remain, so not running&#8221;)\u00a0 bgTimer = window.setInterval(&#8220;LoaderEffect()&#8221;,100);<\/p>\n<p>&#8212;<\/p>\n<p><strong>References:<\/strong> (for javascript)<br \/>\n&#8211; <a title=\"http:\/\/www.w3schools.com\/jsref\/met_win_setinterval.asp\" href=\"http:\/\/www.w3schools.com\/jsref\/met_win_setinterval.asp\" target=\"_blank\">http:\/\/www.w3schools.com\/jsref\/met_win_setinterval.asp<\/a><br \/>\n&#8211; <a title=\"http:\/\/www.w3schools.com\/jsref\/met_win_clearinterval.asp\" href=\"http:\/\/www.w3schools.com\/jsref\/met_win_clearinterval.asp\" target=\"_blank\">http:\/\/www.w3schools.com\/jsref\/met_win_clearinterval.asp<\/a><br \/>\n&#8211; <a title=\"http:\/\/www.w3schools.com\/jsref\/prop_style_backgroundcolor.asp\" href=\"http:\/\/www.w3schools.com\/jsref\/prop_style_backgroundcolor.asp\" target=\"_blank\">http:\/\/www.w3schools.com\/jsref\/prop_style_backgroundcolor.asp<\/a><br \/>\n&#8211; <a title=\"http:\/\/stackoverflow.com\/questions\/1484506\/random-color-generator-in-javascript\" href=\"http:\/\/stackoverflow.com\/questions\/1484506\/random-color-generator-in-javascript\" target=\"_blank\">http:\/\/stackoverflow.com\/questions\/1484506\/random-color-generator-in-javascript<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Webgl build progress meter seems stuck at the end sometimes, so it would be nice to have some &#8220;loading\/uncompressing&#8221; effect there.. WebGL example: http:\/\/unitycoder.com\/upload\/demos\/CustomWebGLLoader\/ *its copy of my LudumDare32 entry &#8211; Caching seems to cause some problems though, effect starts too early or too late? [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3796,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[420,3],"tags":[568,50,733,320],"class_list":["post-3793","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","category-unity3d","tag-custom","tag-effect","tag-loading","tag-webgl"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/webgl_effect.jpg?fit=680%2C414&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-Zb","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/3793","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=3793"}],"version-history":[{"count":10,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/3793\/revisions"}],"predecessor-version":[{"id":3809,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/3793\/revisions\/3809"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/3796"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=3793"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=3793"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=3793"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}