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 NinjaRubberBand · Feb 17, 2014 at 06:44 PM · resolutionscreenguitext

Fit GUIText in every resolution

Ok, so this may be a very duplicated question, but i havent found an answer. Basically what i want is a way to make my GUIText stay, regardless of what. So if the guitext is at the bottom center and i change the resolution, the guitext is still at the bottom center.

I know i have to use Screen.width and height but i just can't figure it out. Ive been working with it all day and my brain just cant think straight. Hope anyone can give me a simple solution to my problem. :-)

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by zharik86 · Feb 17, 2014 at 07:03 PM

Watch my answer to your pregoing question answers.unity3d.com/questions/642044/android-screen-size-script-not-working.html

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

Answer by ivan2532 · Feb 17, 2014 at 07:13 PM

You can make a GUI.Box without texture... And implement this code:

 var guiSkinForBox : GUISkin;
     
 function OnGUI()
 {
     GUI.skin = guiSkinForBox;
     GUI.Box(Rect(0, 0, Screen.width, Screen.height), "Text here...");
 }

Good luck!

Comment
Add comment · Show 3 · 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 NinjaRubberBand · Feb 17, 2014 at 07:26 PM 0
Share

Doesn't help, the screen gets darker when using it .. Isnt there a way to just do it with a normal guitext?

avatar image RafaelCN · Feb 17, 2014 at 07:28 PM 0
Share

Of course it gets darker, its a Gui.Box in the entire screen, I will wrote an answer :p

avatar image NinjaRubberBand · Feb 17, 2014 at 07:31 PM 0
Share

But i don't need a guibox that makes the screen darker.. I want a guitext .. D:

avatar image
0

Answer by RafaelCN · Feb 17, 2014 at 07:33 PM

Ok so you need a "responsive" layout, I have made an API to provide me that, and I will show a little functions to show to you how to do that.

  public bool createButton(float left, float top, float width, float height, String value) 
         {
             return GUI.Button(new Rect((screenWidth-screenWidth)+left, (screenHeight-screenHeight)+top, 
                                                                                 width, height), value);
         }

ScreenWidth and ScreenHeight:

 //Get the screen width and height
     public int getScreenWidth       { get; set; }
     public int getScreenHeight      { get; set; }
 
     private int screenWidth = Screen.width;
     private int screenHeight = Screen.height;

What the code does? The function that I've created a function to create a Button, the function takes the size of the screen, and make a button with: the size of the screen - the size of the screen(it makes the screen positioning 0) more the position that you have inserted on the function.

Comment
Add comment · Show 6 · 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 RafaelCN · Feb 17, 2014 at 07:34 PM 0
Share

@NinjaRubberBand you can make your own function to make exactly what I've done :D

avatar image NinjaRubberBand · Feb 17, 2014 at 07:37 PM 0
Share

Ok im really confused.. Why isnt it possibly to just make a simple guiText and make it stay at every resolution???

avatar image RafaelCN · Feb 17, 2014 at 07:39 PM 0
Share

It's easy as I said, create your function createGuiText(arguments...), I've made a createLabel(arguments...) to create a Label on the screen for me, it works perfectly, just think a little more, when the difficult comes, you just need a motive to pass through it!

avatar image NinjaRubberBand · Feb 17, 2014 at 07:47 PM 0
Share

Its really hard to see what this is when you are 15 years old and don't have english as mother language. And im only 2 months into scripting so there is a lot i really don't understand.

It would be very nice if you could make a scene where you showed it. Just a fast setup. I just cant see how i can use this, its always easy when you understand what is going on.

avatar image RafaelCN · Feb 17, 2014 at 07:56 PM 0
Share

I began to develop when I was fourteen, and as you, I don't have english as a mother language. I used to have a lot of trouble with that, and then I realize that I have to learn how to program first, improve your logic first, methods, arrays, pointers, class, OOP. Ok, let's focus, I've have two classes, one in the camera, and one is my API that provide me the functions that i said. Here is a sample of what my API does with the script on the camera

alt text

alt text

How I use my API:

 _screen screen      = GetComponent<_screen>();
 _systemInfo system  = GetComponent<_systemInfo>();
 
         screen.createLabel(10, 10, 220, 50, "OS: " + system.OperatingSystem);
         screen.createLabel(10, 50, 220, 50, "Processor: " + system.Processor);
         screen.createLabel(10, 100, 220, 50, "Graphic Card: " + system.GraphicCard);
         screen.createLabel(10, 140, 220, 50, "Graphic Card $$anonymous$$emory: " + system.Graphic$$anonymous$$emory);
 
         screen.createLabel(screen.getScreenWidth-100, 10, 200, 20, 
                             "Width: "+screen.getScreenWidth.ToString());
 
         screen.createLabel(screen.getScreenWidth-100, 30, 200, 20, 
                             "Height: "+screen.getScreenHeight.ToString());

It is a little bit complicated if you are novice in program$$anonymous$$g, but it became understandable when you practice your OOP, and method creation...

Hope it help :D

game.png (23.0 kB)
Show more comments

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

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

Related Questions

Make buttons visible in the editor? 2 Answers

How to make my game fit into my droid? 1 Answer

How to maintain high resolution custom background images for GUI elements on different screen sizes? 0 Answers

Pick sensible resolution for FullScreen Mac App 2 Answers

Screen.SetResolution doesn't work when the game starts windowed? 0 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