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
1
Question by grimmy · Nov 03, 2011 at 04:19 PM · webplayeraspect-ratiocss

How can I maintain webplayer aspect ratio on a web page using CSS

I have browsed the CSS forums but nothing that they suggest for maintaining aspect ratios of images and divs seem to work? I want the player to scale fluidly if the user scales the browser window.

Has anyone ever done this? I find it difficult to believe nobody has ever tried using the webplayer on a fluid webpage layout.

Note: My game GUI code works fine, its the proportions of the overall Unity window that I want to maintain. (ie even if the window contained nothing it should still be 4:3)

In my javascript file I have tried using:

 unityObject.embedUnity("unityPlayer", "http://myGame.unity3d", "100%", "100%",params);

but proportions are lost. And if I do a fixed pixel size then obviously the Unity window wont scale to fir the browser window.

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 tomekkie2 · Jun 07, 2012 at 02:13 PM

Most common flexible layout is the full browser layout and that is easy and there are plenty of examples for that in the web. In your case you can setup the special javascript functions:

  1. body onload:

  • calculate the browser window size, set the css dimensions, embedUnity with "100%", "100%" in the containing div tags
    1. window.onresize:

  • recalculate the browser window size, set new css dimensions for the div tags containing the WebPlayer - in case of resize event

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 tomekkie2 · Jun 15, 2012 at 07:09 PM 0
Share

Go to see this working: http://virtualplayground.d2.pl/WP/?p=367

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Scale WebGL cavas to browser window size 0 Answers

Webplayer interaction between 3d scene and text on webpage 1 Answer

webplayer resolution problems/issues/oddities and frame rate weirdness 6 Answers

Webplayer - How to preserve aspect ratio in full screen? 1 Answer

How to format Unity's 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