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 thearch · Sep 04, 2014 at 05:19 PM · guitextureloadlevelgui-button

Button function Problems

Hi all,

Im having a problem about the button function. I made a GUI button from start menu then loads up the game and it did well, but i dont want to use the background of the GUIButton and I manage to remove the main texture and link the button texture to GUITexture , but the original texture of the GUIbutton is is still appearing and i don't have access re sizing and re positioning the gui texture. So I created a new script to attached to GUITexture (withoutGUIbutton) , and it works but the problem is my main character seems to appear way back -Y positon (im creating 2d game) , unlike the GUIButton it starts well without any problem. GUIButton problem is not appearing correct size and position after building and playing in tablet. GUITexture gives me the correct size and correct position. any advice and help? Please..

Thanks

Comment
Add comment · Show 2
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 Zephrim · Sep 04, 2014 at 08:03 PM 0
Share

This doesn't answer your question, but I really suggest you watch some of these videos and decide whether or not you think using Unity 4.6 would be a better option then using the old gui system.

Videos

Unity 4.6 (I personally use Unity 4.6 Beta 17 since Beta 18 is still in an early testing phase)

avatar image thearch · Sep 06, 2014 at 04:28 AM 0
Share

I tried the new version and does the same problem from the old one.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by zharik86 · Sep 06, 2014 at 07:49 AM

If you use GUITexture, you should scale objects independently for different display resolutions. I will write a small script(write on CSharp):

  //define here the original resolution. For it you set all position and the sizes of your GUITextures.
  public float origW = 1280;
  public float origH = 720;
 
  void Start() {
   float scaleX = (float)(Screen.width) / origW; //your scale x
   float scaleY = (float)(Screen.height) / origH; //your scale y
   //Find all GUITexture on your scene
   GUITexture[] textures =  FindObjectsOfType(typeof(GUITexture)) as GUITexture[];
   foreach(GUITexture myTexture in textures) { //find your element of texture
    Rect pixIns = myTexture.pixelInset; //your dimention of texture
    //Change size pixIns for our screen
    pixIns.x = pixIns.x * scaleX;
    pixIns.y = pixIns.y * scaley;
    pixIns.width = pixIns.width * scaleX;
    pixIns.height = pixIns.height * scaleY;
    //Sets new rectangle for our texture
    myTexture.pixelInset = pixIns;
   }
  }

If you want to create GUIButton with other texture, it is best of all to create new GUIStyle. In it you can change a texture. However, in most cases, it is better to create a set of styles: GUISkin. I hope that it will help you.

Comment
Add comment · Show 2 · 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 thearch · Sep 07, 2014 at 06:19 AM 0
Share

thanks @zharik86 I would try this code and update if i dont get any issue.. thanks...appreciate it.

avatar image zharik86 · Sep 07, 2014 at 07:20 AM 0
Share

@thearch If I helped you, you can mark a my answer.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to make a GUI button invisible? 1 Answer

Error : Expressions in statements must only be executed for their side effects. 1 Answer

AdMob makes my game do strange things 0 Answers

Reduce Draw call for Multiple GUI Textures with same Texture 1 Answer

Making a Health Bar with Code 5 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