Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Wolfrik_Creations · May 22, 2016 at 06:48 AM · javascriptguionguiwindowgui.window

GUI.Window only shows for one frame under all circumstances

Okay, this is really starting to annoy me as I've tried to fix it for over a week now and the internet doesn't help at all because people keep asking this question saying that they put the window call in a GUI.Button statement.

GUI.Window will NOT render for me even if I put it under the OnGUI function with nothing else in there.

I've tried GUI.Window and GUI.ModalWindow (which is what I'm aiming to do).

Please help me fix this, I've also tried putting it in multiple different scripts and it will not work, here's something similar to what I'm doing:

 function OnGUI(){
    GUI.Window(0, Rect(0, 0, 1920, 950), StupidAssWindow, "The non-renderer");
 }
 
 function StupidAssWindow(id : int){
   print("I don't ever print to the console");
 }

That's not the exact code I use but I only have different names set, this won't work. Please help me.

And if you can find the fix in C# I can understand C# nearly as well as JS so I can translate it fine.

Comment
Add comment · Show 1
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 Wolfrik_Creations · May 26, 2016 at 11:08 PM 0
Share

I just moved this question from Help Room to Default to see if that will help, I still can't fix this issue.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Wolfrik_Creations · May 27, 2016 at 04:12 PM

After over two weeks I finally figured it out! I feel like such a dumbass now,

Children, DO NOT PUT useGUILayout = false; IN YOUR GUI SCRIPT IF YOU WANT WINDOWS!

I don't even know what that statement does but it was in my script and that's what caused it to not work. Thank you everyone for your help, without you I wouldn't have looked at that line of code.

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 Bunny83 · May 26, 2016 at 11:22 PM

I just tried your exact example code and it works as expected. I get an empty window that covers the whole screen and each frame i get two times the line "I don't ever print to the console" ...

I could have told that without even trying but i just want to be sure as i never use UnityScript.

So if it doesn't work for you, there must be something else going on. Are you sure your script is enabled and doesn't get disabled be some other script? Same for the gameobject it's attached to. Maybe you disable or destroy the gameobject somewhere?

Try adding:

 function Update() {
     print("Update, yeah");
 }

and see if that prints. If not your script is most likely not enabled or not there anymore.

edit

As i already wrote in the comment below (which got burried under several other comments) the reason why your GUI.Window doesn't work is because you disabled the Layout event.

See the documentation for more details:

if MonoBehaviour.useGUILayout is set to false then a call to GUI.Window will not have any effect, even though it is not a GUILayout function.

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 Wolfrik_Creations · May 27, 2016 at 12:06 AM 0
Share

The script I'm using is over 2,000 lines of code and it's really important so it's never disabled, in fact it is attached to my player.

avatar image Bunny83 Wolfrik_Creations · May 27, 2016 at 12:30 AM 0
Share

Well, it does work Are you sure that's the only window you try to display? $$anonymous$$eep in $$anonymous$$d that every window need a unique window ID. You can't have two windows with the same ID.

avatar image Bunny83 Bunny83 · May 27, 2016 at 03:18 AM 1
Share

Well you disabled the Layout event, that's the reason why the Window doesn't work. GUI.Window needs the Layout event. Just read the documentation:

[...] if $$anonymous$$onoBehaviour.useGUILayout is set to false then a call to GUI.Window will not have any effect, even though it is not a GUILayout function.

That matrix shouldn't cause that much problems as long as your native_width /_height have reasonable values.

Show more comments
avatar image ninja_gear Wolfrik_Creations · May 27, 2016 at 02:59 AM 1
Share

well if u have one script that is 2000 lines long ... wow. I have a 500 script RPG project atm, and even CombatReferee.cs (the longest script) is only 500 lines. I would srsly suggest for your own peace of $$anonymous$$d and for readability that you attempt to break up that monster. It might make finding small problems like this easier.

I$$anonymous$$HO its always good to take a break from progress with the project to sit back, collect on how far you have come and try to tidy up. Good luck with your project!

avatar image Wolfrik_Creations ninja_gear · May 27, 2016 at 03:05 AM 1
Share

I do that, every few weeks I build the game and debug the multiplayer with my friends and we build a huge house in-game and then blow it up and watch the glory.

I have multiple scripts nearly as long as 2k lines, I keep them in one script for effeciency and performance, the game looks really good and runs amazingly even on shitty laptops and such, zombies and structures have no performance affect due to my way of coding and I rarely ever use the stupid Update or FixedUpdate functions as they highly drain performance, use true loops ins$$anonymous$$d.

And, thank you!

Show more comments
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

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

Related Questions

using GUI scrollView for multiple onGUI functions 0 Answers

GUI.Window Problem Option Menu 1 Answer

GUI opacity. 1 Answer

Open window GUI when I touch the object in iOs (javascript) 1 Answer

Setting Scroll View Width GUILayout 1 Answer


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