So what I'm trying to do is create 4 Textures overlap each other, so they have the same x and y position as well share a height and width. But I'm using GUILayout for screen resizing and placement issues that GUI just wasn't solving. Here is a snippet of code...
So those Boxes I want to be overlapping each other in the same position on the screen. But I want to be able to place those boxes in a position on the screen using the GUILayout. I'm hoping for anyone that can give me some good alternatives, but please no one responding with telling me to switch over to GUI.DrawTexture. I know that I can do it with that, but I get sizing and spacing issues with the screen resizing itself if I do that.
Answer by AzulValium
Feb 28, 2012 at 01:40 AM
I know this is an old thread, but you can use GUILayoutUtility.GetLastRect().
GUI.Box( GUILayoutUtility.GetLastRect(), circleImageTwo);
You sir, are my hero. I would upvote this answer but I don't have enough rep yet.
@mikeschuld upvoted for you
Thanks, your example helps me.
Have an upvote, good sir/madam. You've saved me from a considerable time futzing around with trying to negatively-space an element.
Well thank you very much, this was so long time ago I can believe is still useful ! haha
Answer by Justin Warner
Dec 08, 2011 at 02:37 PM
As no one has posted yet, I'll just add my two cents. I don't see why you need the GUILayout if you want them stacked... I think it'd be more ideal if you were to use the normal GUI.DrawTexture, stack them that way, and find work arounds to work with different resizes... GUILayout is for automatic layouting, not for putting things where you want them to be... Whether you just make the location the Screen.width/2 and Screen.height/2 or make the location simple 0,0 and then change the sizes to change with the Screen.width/Screen.height.
I just can't see resizing being such an issue unless you're making your screen small as no other... A general rule (In my opinion) is if it works in the Web View, you're fine. That's the smallest anyone will be going unless you're developing for Android/iOS, which you could be, in that case, I'd still suggest finding a work around hah. But yeah. Good luck! (Look around the API/search Google, I'm sure someone has had this problem lol).
Well I'm no exactly positive about this, but it's going to be a standalone application first. And I'm trying to compensate for the user being a dick when it's in windowed mode, and finding a way to break the game, and then bitching about it. What I like about GUILayout is that if you just supply a min and max of the images, then it will resize the images and their spacing with one another while keeping the ratio of the images, without having to do a lot of math and adding to the complexity of the code.
So that's why I was hoping to do it with GUILayout and not GUI. But looks like I'm going to have to do just that one part in GUI over top GUILayout. And that makes me sad.
Well, could check every one in a while if the screen was resized, if so, put a registry key in to disable running the game, shut it off, then when he restarts it, give a warning that if it's done again, that he won't be able to play again... Dick move, but works too ;).
Hahaha, I want people to keep playing my game though. :P I'll figure something out. Thanks for the options and opinions though.
http://answers.unity3d.com/questions/21550/automatic-screen-resize.html Should work.
Answer by ks13
Dec 10, 2011 at 03:44 PM
Hi, i think you can make the window no-resizable...not 100% sure though.
Now that I think I may be interested in. I'll have to look more into that, thanks for the suggestion.
If anyone knows how to make it so that the player can't resize the window, then I'm very interested in this. Thanks for any info, I'm still researching trying to find out how, but let me know.
Ok, sorry, this is my misunderstanding. Since i'm learning C# at same time as using Unity 3D, i mixed resizing mode in C# and GUI.Window in Unity. But, knowing that Unity allows native language imported scripts, you should be able to make a script using this C# property and make the window not unresizable. Here's the link : Windows Class
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
7 People are following this question.
GUILayout Draggable Window
Gui now showing up! Nothing to do D':
GUI.Window called 2 frames ahead than OnGUI?
How to disable horizontal scrollbar in GUILayout scroll view?
GUI Error: You are pushing more GUIClips than you are popping?