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 KnightRiderGuy · Nov 27, 2014 at 05:33 AM · guilayoutguistylescreen resolutionscreen size

Why does my GUI layout get messed up in player

When I publish to the stand alone player all of my GUI elements and texture GUI buttons are all out of whack.... Why? How can I fix this? What I see in the game editor is not what I get when published.

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 meat5000 ♦ · Nov 27, 2014 at 03:45 AM 0
Share

GUITextures? Use transform to position ins$$anonymous$$d of pixel offsets.

avatar image Joe_User · Nov 29, 2014 at 07:38 PM 0
Share

Just a suggestion, but have a look at the new UI features in 4.6. A significant amount of the positioning and sizing for multiple resolutions is taken care of for you.

Of course switching to the new UI might not be feasible if you've got a large investment in the old methods. It was a difficult decision here... :-) I think it paid off, though.

avatar image fafase · Nov 29, 2014 at 07:56 PM 0
Share

Actually, switching to the new system is not a big issue even if you have a large amount of old GUI. This is due to the fact that most is manual and visual so only the actions for the events remain in the end. I would also recommend the move to the uGUI.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by fafase · Nov 27, 2014 at 05:38 AM

What you see in the editor is probably based on the current size of it. GUITexture and other GUI component requires a hardcoding system most of the time.

If you place them at 0.5, 0.5 then it will be in the middle all the time, but I have noticed that if you parent the object, then it does not work.

What I do is to make them child so that it is clean in the hierarchy, and then modified the pixelInset by code.

 void Start(){
     float size = Screen.width /20f;
     Rect r = new Rect(Screen.width - size, 0, size, size);
     guiTexture.pixelInset = r;
 }

I think this will go top right corner but you get the idea that it will get always in the same spot.

Comment
Add comment · Show 12 · 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 KnightRiderGuy · Nov 27, 2014 at 02:17 PM 0
Share

Thanks fafuse, that was very helpful. Also I'm trying to make my final out put for touch screen LCD car monitor that has a resolution of 800 X 480 and I notice that the player does not have that option so I'm thinking that also might be part of my problem, will the method you described above fix this issue too?

avatar image KnightRiderGuy · Nov 27, 2014 at 02:39 PM 0
Share

Oh one more thing, is this java because I pated it in just to try it out and it gave me errors saying that I needed to : Assets/Scripts/HomeScreenLoaderButton.js(3,10): UCE0001: ';' expected. Insert a semicolon at the end.

and

Assets/Scripts/HomeScreenLoaderButton.js(2,11): UCE0001: ';' expected. Insert a semicolon at the end.

avatar image fafase · Nov 27, 2014 at 06:16 PM 0
Share

First you can set the resolution of your screen to whatever you want in the editor. In the game view, you have the list of resolution and if you click the plus, you can make your own.

The code is C# but the same goes for UnityScript:

 void Start(){
     var size : float = Screen.width /20f;
     var r : Rect = Rect(Screen.width - size, 0, size, size);
     guiTexture.pixelInset = r;
  }
avatar image KnightRiderGuy · Nov 27, 2014 at 09:07 PM 0
Share

Thanks again, :) It's been a little while since I had played around with Unity and I forgot all about the editor view option, this gives me a much better idea of how things will look. I keep doing test builds to see if it all fits right on screen lol I pasted that code into the top of my buttons script and I still get those same errors??

avatar image KnightRiderGuy · Nov 29, 2014 at 01:22 PM 0
Share

Somewhat related is another issue I'm having trying to get a GUI texture background to stay behind my other texture GUI elements. Even an animated GUI texture to stay overtop of everything so as when the animation is finished then everything on the screen becomes visible. Can't seem to figure out how to make that work although I'm sure it can be done as I have seen it.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Screen.width/Screen.height not working with multiple resolutions 0 Answers

How to apply multiple styles to the same line(s) of GUI text 1 Answer

How to set GUIStyle.font 0 Answers

multiple apks to match certain devices 0 Answers

How to change the color of a GuiLayout.button thats part of the editor 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