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
0
Question by lauralynn · Nov 28, 2012 at 06:29 AM · webplayerresizing

Trouble resizing webplayer

I'm trying to resize my webplayer to fit a user's browser window. Here's my javascript in the html header:

     if (typeof unityObject != "undefined") 
 {
 //get the width of the window
 var winW;
 if (window.innerWidth)
 {
 winW = window.innerWidth;
 }
 else if (document.body && document.body.offsetWidth) //IE
 {
 winW = document.body.offsetWidth;
 }
 //set params
 var params = 
 {    
 backgroundcolor: "ffffff",
 bordercolor: "ffffff",
 textcolor: "000000",
 logoimage: "logo_webplayer.png",
 progressbarimage: "GUI_loading_filled.png",
 progressframeimage: "GUI_loading_empty.png"       
 };
 //embed the player
 unityObject.embedUnity("unityPlayer", "fit2cure.unity3d", 1060, 600, params);
 //get the player
 var unity = unityObject.getObjectById("unityPlayer");
 if (unity == null) {
 unity = document.getElementById("UnityObject");
 }
   if(unity == null) {
 unity = document.getElementById("UnityEmbed");
 }
 //set the width of the player
 if (unity != null) 
 {
 alert("not null");
 unity.style.width = winW;
 unity.style.height = 600 * winW / 1060;
 }
 else
 {
 alert("null");
 }
 }
 

Through alerts I've figured out that winW is getting the correct width and that despite trying to get the unityPlayer all different ways, it is still null when I try to set the width and height. What else should I try?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Flynn · Nov 28, 2012 at 06:32 AM

You can do this without JS thankfully! :)

Just start your webplayer up like this:

 unityObject.embedUnity("unityPlayer", "fit2cure.unity3d", "100%", "100%", params);

Then carefully set up all of your container objects to also have maximum width with no padding, border, or margin.

Good luck!

EDIT: on a side note, is it unity.style that is null? instead of unity?

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

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

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers

Is WWW class usable in Android platform? 1 Answer

Games on My Own Website 1 Answer

specify adress of "webplayer.unity.3d" in "webplayer.html"? 2 Answers

Is dynamic font supported on webplayer? 1 Answer


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