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 letsfailsafe · Sep 23, 2013 at 10:49 AM · resolutionscreenmenu

Creating responsive menu

I've created a game menu using JavaScript and GameOjbect - 3D Text.

The menu is designed for 1080p screens only so its not responsive. All 3D Texts' positions are fixed positions and they get cut away if any screen with resolution less than 1920 X 1080 is used.

What is the best way to solve this problem? (I've done some research and one of the responsive menu build was too complicated...)

Comment
Add comment · Show 3
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 Tanshaydar · Sep 23, 2013 at 09:05 PM 0
Share

Why are you using fixed positions? All other resolutions will have problems with it. You can use Screen for example, or use profiler to see different resolutions how it looks.

avatar image letsfailsafe · Sep 24, 2013 at 07:35 AM 0
Share

Sorry I don't quite understand. Is it possible to use

 if(GUI.Button(new Rect(Screen.width-100,20,70,28)

width statement for GameObjects - 3D Text like I used it for the GUI button

avatar image Tanshaydar · Sep 24, 2013 at 10:14 AM 0
Share

Screen is just a class, holding parameters for you. You can use it anywhere in the game, in any way you want. But you should see how your camera handles the positioning in different resolutions.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by robhuhn · Sep 24, 2013 at 10:19 AM

Have a look here:

http://answers.unity3d.com/questions/520583/how-can-i-place-3d-text-to-the-corner-of-the-scree.html

Comment
Add comment · Show 5 · 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 letsfailsafe · Sep 25, 2013 at 11:33 AM 0
Share

Here is my script which I have attached to a 3D Text:

 using UnityEngine;
 using System.Collections;
 
 [RequireComponent(typeof(Renderer))]
 public class ResponsiveTest: $$anonymous$$onoBehaviour 
 {
     public Vector2 screenPosition = new Vector2(0, 0);
  
     void Update () 
     {
        Vector3 tempScreenPosition = screenPosition;
        tempScreenPosition.z = -Camera.main.transform.position.z;
  
        Vector3 worldPosition = Camera.main.ScreenToWorldPoint(tempScreenPosition);
        worldPosition.x -= renderer.bounds.size.x * tempScreenPosition.x / Screen.width;
        worldPosition.y += renderer.bounds.size.y * (1 - tempScreenPosition.y / Screen.height);
        transform.position = worldPosition;
     }
 }

And this is my menu button script (JavaScript): #pragma strict //The main menu script

 private var ray : Ray;
 private var hit : RaycastHit;
 
 function Update() 
 {
     if(Input.Get$$anonymous$$ouseButton(0))
     {
         ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         
         if(Physics.Raycast(ray, hit))
         {
             if(hit.transform.name == "Text(Play)")
             {
                 Application.LoadLevel("Landing");
             }
         }
     }
 }
 
 //Colour change
 function On$$anonymous$$ouseEnter()
 {
     renderer.material.color = Color.green;
 }
 
 function On$$anonymous$$ouseExit()
 {
     renderer.material.color = Color.white;
 }


Now my 3D Text is responsive but button control stopped working... What is wrong?

avatar image robhuhn · Sep 25, 2013 at 11:58 AM 0
Share

The first script shouldn't block the second script. Do you still have a collider attached?

avatar image letsfailsafe · Sep 26, 2013 at 06:31 AM 0
Share

Yes the collier is still attached... I'm not quite sure why its not working. Also would you be able to explain in detail what each statement does. Trying to understand it but not quite get it...

avatar image robhuhn · Sep 26, 2013 at 07:10 AM 0
Share

Yes, the calculations prevent only the need to change the anchor of the text mesh (the anchor should be always in the upper left here).

Get the world position:

 Vector3 worldPosition = Camera.main.ScreenToWorldPoint(tempScreenPosition);

Calculate the position/screen ratio

 //returns a float 0 to 1 where 0 is left and 1 is right 
 tempScreenPosition.x / Screen.width 

$$anonymous$$ultiply that by the meshs width to get the desired offset

 //gives 0 offset on the left (we need no offset because the anchor is also left)
 //and the meshs width on the right. 
 renderer.bounds.size.x * ratio

Finally subtract this value

 worldPosition.x -= offset

So the more the mesh moves to the right the higher the offset in relation to the mesh.width/screen.width-ratio to compensate the meshs anchor position.

avatar image GluedBrain · Sep 08, 2014 at 10:01 AM 0
Share

If you don't $$anonymous$$d recreating your menu, then you should possibly look at the all new Unity 4.6 UI system. it's simple and powerful. Anchors is the word you should be looking for. Place the anchors of the UI element to the corners. That's it, the UI element is responsive. Check the below link for more info

Dyanmic $$anonymous$$enu Unity 4.6

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

17 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

2D Game. Screen, Camera and coordinates. 0 Answers

Reading Screen Dimension in Android Immersive Mode 1 Answer

Asset Variations for Different Mobile Screen Sizes 1 Answer

Max Resolution? Targeting 4320x5400 px... 1 Answer

Auto scaling GUI 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