Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Grasshorse · Jun 11, 2011 at 03:37 AM · resolutionguitextureaspect-ratiodrawtexture

resolution/aspect ratio independent bg texture

Hello,

I'm trying to make a resolution/aspect ratio independent GUI and I want to have a image that is behind a GameObject that is in the scene. Here is what I have tried.

  1. Make it a GUITexture. That didn't work because it wouldn't float, plus it covered the GameObject in the scene.

  2. Just make it a regular object and place it just above in Y space (top down layout). This was successful in being behind the GameObjects but was not when the scene changed it's aspect ratio.

  3. Write a script that will look at the Screen.width and Screen.height and pass the desired vector3 placement through a camera.ScreenToWorldPoint() operation so that it will find the correct X and Z values to match the other GUI elements (which I have successfully placed and scaled. I am missing something here, and I haven't found anything in the forums that deals with this specific issue. Here is the code for the failed attempt.

var prefab:GameObject;

var quickSelectBackPlacementX = (Screen.width * 0.9);

var quickSelectBackPlacementY = .01;

var quickSelectBackPlacementZ = (Screen.height * 0.9);

var quickSelectBackPlacement = Vector3(quickSelectBackPlacementX,quickSelectBackPlacementY,quickSelectBackPlacementZ);

var quickSelectBackCoord;

function Start()

{

 quickSelectBackCoord = camera.ScreenToWorldPoint(quickSelectBackPlacement);
 
 quickSelectBackCoord.y = quickSelectBackPlacement.y;
 
 var quickSelectBackPos = Vector3(quickSelectBackCoord.x,quickSelectBackCoord.y,quickSelectBackCoord.z);

 var quickSelectBack = GameObject.Instantiate(prefab, quickSelectBackPos, Quaternion.identity) as GameObject;

}

Does anyone have any ideas about how this effect might be achieved? All ideas are welcome.

Best Regards,

Steve

Comment
Add comment · Show 1
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 Grasshorse · Jun 11, 2011 at 03:44 AM 0
Share

Also, please let me know how I can format my code better!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ninthjarl · May 08, 2012 at 12:15 PM

Hi, I do not understand your exact implementation but if your game object is always facing the camera then you could try using a billboard behind your gameobject. I have never implemented that in Unity but it is basically a plane that always faces the camera in 3D.

All the best.

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

2 People are following this question.

avatar image avatar image

Related Questions

ASPECT RATIO FILTER IN OnGUI? 3 Answers

Keep Aspect ratio/Letterbox and maintain pixel perfection 0 Answers

Camera horizontal distortion? 1 Answer

Keeping Aspect Ratio without filling screen 0 Answers

Best approach to define interactive screen areas regardless of it's resolution? 3 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