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 Madswint · Dec 12, 2013 at 06:37 PM · guiresizeguiwindow

How can I put this function in GUI Window?

 shopWindow = GUI.Window (0, shopWindow, DoMyWindow, "Shop");
 
 How do I put this function 
 
 function ResizeGUI(_rect : Rect) : Rect
 {
     var FilScreenWidth = _rect.width / 800;
     var rectWidth = FilScreenWidth * Screen.width;
     var FilScreenHeight = _rect.height / 600;
     var rectHeight = FilScreenHeight * Screen.height;
     var rectX = (_rect.x / 800) * Screen.width;
     var rectY = (_rect.y / 600) * Screen.height;
  
     return Rect(rectX,rectY,rectWidth,rectHeight);
 }
 
 Into the window script as I did with buttons:
 if (GUI.Button(ResizeGUI(Rect (197,20,105,30)), "")) {
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 Josh707 · Dec 12, 2013 at 06:52 PM 0
Share

Your ResizeGUI function takes type Rect as a parameter as default values and returns a Rect, so you can supply this function as the rect parameter when using GUI.Window

 shopWindow = GUI.Window(0, ResizeGUI(shopWindow), Do$$anonymous$$yWindow, "Shop");
avatar image Madswint · Dec 12, 2013 at 07:21 PM 0
Share

If I do that, it makes it go beserk, resizing every frame and dissapear

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Sundar · Dec 12, 2013 at 06:53 PM

Have you tried this

 if( resizeWindow ) 
 {
     shopWindow = ResizeGUI( shopWindow );
     resizeWindow = false;
 }
 shopWindow = GUI.Window( 0, shopWindow, DoMyWindow, "Shop" );
Comment
Add comment · Show 7 · 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 Josh707 · Dec 12, 2013 at 06:56 PM 0
Share

I thought that at first but setting shopWindow to it will cause shopWindows values to be divided every time, causing it to screw up horribly

avatar image Sundar · Dec 12, 2013 at 07:08 PM 1
Share

Thanks Josh707, yes you are right. Excalibera resize window only when you need it to be resized.

avatar image Madswint · Dec 12, 2013 at 07:19 PM 0
Share

I need it to be resized automaticly, that's the problem :/

avatar image Sundar · Dec 12, 2013 at 07:24 PM 0
Share

There must be a reason why you need to resize window? Check your logic, you will find it.

avatar image Madswint · Dec 12, 2013 at 07:26 PM 0
Share

I'm not getting what you mean, I have no idea how to put this into a window :/. I need to resize the window, because it's a web player, and every player has a different screen dimension, so it has to resize itself, since the webplayer is set to fill the whole browser window.

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

18 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

Related Questions

Help Changing GUI Text size 0 Answers

New 4.6 UI question: How do you resize a panel relative to the screen but remain height/width constrained? 5 Answers

How can I resize an image with drag-and-drop? 1 Answer

GUI.Window called 2 frames ahead than OnGUI? 0 Answers

What is the best way to resize textures on the 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