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 zer0c00l42066 · Nov 28, 2013 at 07:23 AM · javascriptgui

Cant get my gui in the quiwindow to load there functions...

 #pragma strict
 var urlpath : String = "";
 private var showWindow : boolean = false;
 function OnGUI () 
 {
     if (GUILayout.Button("Inventory"))
 {
     showWindow = true;
 }    
  
 if (showWindow)
 {
         GUI.Window(5,Rect((Screen.width/2)-(300/2),(Screen.height/2)-(300/2),300,300),OnWindowDraw5,"Inventory");
 }
 
 } 
  function Start () {    
 }
 
  function load() {
     var testobj : GameObject;   
     testobj = new GameObject ("object");
     testobj.AddComponent (OBJ);
     var targetComp : OBJ = testobj.GetComponent(OBJ);
     targetComp.objPath = urlpath ;
     testobj.AddComponent (MeshCollider);
     yield WaitForSeconds(3);
     var targetComp2 : MeshCollider = testobj.GetComponent(MeshCollider);
     var targetComp3 : MeshFilter = testobj.GetComponent(MeshFilter);
     targetComp2.sharedMesh = targetComp3.mesh;
    
 }
 
 function OnWindowDraw5(winid:int)
 
 {
     
 if (GUI.Button(Rect(15,98,79,22),"Spawn1"))
     
 {
     urlpath = "http://www.gamesite.x10.mx/OBJs/monkey.obj"; 
     load();    
 }
     
 if (GUI.Button(Rect(203,101,79,22),"Spawn3"))
     
 {
     
 }
 if (GUI.Button(Rect(265,5,30,15),"X"))
     
 {
     showWindow = false;    
 }
         
 if (GUI.Button(Rect(109,100,79,22),"Spawn2"))
     
 {
     urlpath = "http://www.gamesite.x10.mx/OBJs/tree2.obj" ;
     load();    
 }
     
 GUI.Box(Rect(12,25,85,100),"Monkey");
     
 GUI.Box(Rect(200,26,85,100),"Test");
     
 GUI.Box(Rect(106,25,85,100),"Tree");
 
 }

the bottom of this script in the function OnWindowDraw5(winid:int) when the buttons are pressed nothing happens. i have tested code in the buttons and it works fine.. Its like the cose in the if button blocks arent being called... this is a javascript

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 zer0c00l42066 · Nov 29, 2013 at 08:30 PM 0
Share

would really like any help i could get with this problem.

avatar image ThatsAMorais · Nov 30, 2013 at 03:43 AM 0
Share

I commented out the contents of load and ran it myself, and all the buttons worked, except the ones that were disabled. I think the issue is in your load function with whatever you are trying to accomplish. i can tell you the buttons do work, though.

1 Reply

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

Answer by ThatsAMorais · Nov 30, 2013 at 03:38 AM

The best way to track what is happening when you can't seem to see whether some code is being executed or not is to use the MonoDevelop Debugger. In other words,

  • Run your app,

  • navigate to your test case where the GUI is displaying,

  • go to MonoDevelop

  • add a Breakpoint to the line of code inside the if(button),

  • push the Play button,

  • "Attach",

  • go back to your editor,

  • push the GUI button on your screen

This should cause MonoDevelop to stop execution at the breakpoint if your code is being called. After that you may step through it as you wish.

Comment
Add comment · Show 1 · 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 zer0c00l42066 · Nov 30, 2013 at 06:54 PM 0
Share

the problem was caused by another gui which had a focus setting on it. removed the getfocus and walla. ty :)

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

17 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

Related Questions

GuiTexture For Jump A Character 0 Answers

The first object in selection grid can't be activated. Why? 1 Answer

Temperature Script? 3 Answers

If statement only work once? 1 Answer

gui rotational issues 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