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 Phenelo · Jan 26, 2014 at 03:40 PM · positiontextmeshscaling

Scaling and positioning Text Mesh

Good day guys! Since my other question is unaswered, I'll just ask the core problem.

I'm trying to scale and position my 3D Text Meshes depending on the screen sizes. What happens is when I tried it on another resolution, the GUI goes off the screen.

Here is my method in scaling and positioning:

 void ScaleGUI()
     {
         float originalWidth = 300f, originalHeight = 598f;
         float scaleX = Screen.width/originalWidth;
         float scaleY = Screen.height/originalHeight;
         scale = new Vector3(scaleX, scaleY, 1);
         float positionX = 0f;
         float positionY = 0f;
         GameObject TestGUI;
         
         positionX = (Screen.width) + ((Screen.width) * (TestGUI.transform.position.x/originalWidth));
         positionY = (Screen.height) + ((Screen.width) * (TestGUI.transform.position.y/originalHeight));
         Vector3 oldScale = TestGUI.transform.localScale;
         Vector3 newScale = new Vector3(oldScale.x * scaleX, oldScale.y * scaleY, oldScale.z);
         TestGUI.transform.localScale = newScale;    
         TestGUI.transform.position = new Vector3(positionX, positionY, TestGUI.transform.position.z);
 }

Could someone tell me what's wrong in my solution. By the way, my GUI Camera is positioned at origin and I want to place the TextMeshes relative from there.

Any help would be much appreciated! :D

Comment
Add comment · Show 5
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 Phenelo · Jan 26, 2014 at 11:17 PM 0
Share

Still can't solve this. I'm out of ideas. There's no enough google results for this.

avatar image Lockstep · Jan 26, 2014 at 11:27 PM 0
Share

What exactly are you trying to do? Nobody will be able to help you if you don't say which effect you want to produce.

avatar image Phenelo · Jan 26, 2014 at 11:31 PM 0
Share

Sorry about that. Edited my post. :D

avatar image Lockstep · Jan 27, 2014 at 12:36 AM 0
Share

From what I can see, you have some strange dependencies in your script. If you call this function while having an other resoultion than the original, the scale will change every time even if the resolution stays the same. The new resolution must not depend on the old.

On another note. You seem to want to use this as a GUI. Why don't you just use GUI-Text? This is specially made for GUI and is therefor much easier to handle. Textmesh is made for floating letters in 3D-space.

avatar image Phenelo · Jan 27, 2014 at 01:11 AM 0
Share

I'm actually using GUITexture for icons and such in my other scenes. But I'm having problems with GUIText, like displaying scores for example, I can't get it to work right with other resolutions because the fontSize is forced to constraining proportions, if I'm describing it correctly. Is there a way to stretch the GUIText int x and y axis independently? Thanks!

0 Replies

· Add your reply
  • Sort: 

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

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

Related Questions

2D Gameobject Location and scaling in different screen size(mobile) 0 Answers

How to make cubes between 2 point and stick them together? 0 Answers

Unity canvas keeps changing dimension and position 0 Answers

How do I scale the results of GetCharacterInfo? 1 Answer

Camera rotation around player while following. 6 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