Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Frie · Nov 08, 2011 at 12:52 PM · webplayerloadingwebpage-javascript

Optimal solution to start loading the webplayer on a page upon user input?

Hey all,

I'd like to embed the webplayer in a webpage but not start loading the game automatically. Instead the user's action should start the loading. For example: an image is embedded in the webpage where the webplayer is going to be displayed (same location and size). It says 'click to play'. Upon clicking the image is swapped for the webplayer and the loading/game begins. Does anyone who is more versatile in html, php and/or javascript have an idea how to implement this?

Cheers - Frie

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

5 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by softrare · Nov 08, 2011 at 03:57 PM

That is because you did not include this line in the header:

<script type="text/javascript" src="http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js"></script>

I didn't mention it. Sorry.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Pituli · Feb 23, 2013 at 08:57 PM 0
Share

Hello, i was wondering if this starts loading the game(assets) as soon as the page opens, or does it start after the swap?

avatar image softrare · Feb 23, 2013 at 09:25 PM 0
Share

It should start loading when the swapping was initiated.

avatar image
1

Answer by softrare · Nov 08, 2011 at 01:50 PM

Try this:

<script type="text/javascript">

 function GetUnity() {
     if (typeof unityObject != "undefined") {
         return unityObject.getObjectById("unityPlayer");
     }
     return null;
 }
 function WebplayerLoad() {
     if (typeof unityObject != "undefined") {
         unityObject.embedUnity("unityPlayer", "WebPlayer.unity3d", 800, 600);
     }   
 }

</script>

<img src="/path/to/image" onclick="WebplayerLoad()" />

Report back whether it worked or not :)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by softrare · Nov 08, 2011 at 02:04 PM

or if you insist on swapping remove the img-tag of my last answer and add this to the body section of the html document:

    <script type="text/javascript">
    function swap() {
        var loader = document.getElementById('loader');
        loader.innerHTML = "<div class=\"content\"><div id=\"unityPlayer\"><div class=\"missing\"><a href=\"http://unity3d.com/webplayer/\" title=\"Unity Web Player. Install now!\"><img alt=\"Unity Web Player. Install now!\" src=\"http://webplayer.unity3d.com/installation/getunity.png\" width=\"193\" height=\"63\" /></a></div></div></div>";
        WebplayerLoad();
    }
    </script>
    <div id="loader"><img src="/path/to/image" width="100" height="100" onclick="swap()" /></div>
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Frie · Nov 08, 2011 at 02:59 PM

Thanks for helping out! The swapping works, but instead of loading the application, the placeholder image is swapped for the ""unity web player - install now!" button! :S

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Frie · Nov 08, 2011 at 04:03 PM

That works! Awesome, thank you!!! :)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image softrare · Nov 08, 2011 at 04:10 PM 0
Share

Glad I could help :) Please mark the question as answered then.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How would I go about getting the results of a javascript variable to a string inside script? 3 Answers

How can I load multiple files from a hosted folder? 1 Answer

How would you tell if the webplayer got loaded from web or cache? 0 Answers

Unity Engine not updating to the latest version 1 Answer

Splash screen timer is too fast 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges