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 Paul Ferris · Oct 21, 2013 at 11:47 AM · javascriptgui

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

Essentially what I said in the title. This is my code:

 #pragma strict
 //@ExecuteInEditMode
 
 var customButton : GUIStyle;
 var confirmMenu : GUIStyle;
 var SubMenuBox1 : GUIStyle;
 var SubMenuBox2 : GUIStyle;
 var selGridInt : int = -1;
 var selGridInt2 : int = 0;
 var selStrings2 : String[] = ["Yes", "No"];
 var selStrings1 : String[] = ["Sandbox", "Multiplayer", "Options", "Exit"];
 //var MainMenu:GUISkin;
 //var Rect2 = RectOffset(0,0,10,10);
 //var sliderValue : float = 1.0;
 //private var rctOff : RectOffset;
 
 function Start(){
     
 }
 
 //#if UNITY_EDITOR #endif
 function OnGUI () {
         selGridInt = GUI.SelectionGrid (Rect (Screen.width*0.015625, Screen.height*0.014286, 75, 95), selGridInt, selStrings1, 1, customButton);
         if (selGridInt == 0){
             Application.LoadLevel("gameDemo");
         }
         
         if (selGridInt == 1){
             Application.LoadLevel("");
         }
         
         if (selGridInt == 2){
             //GUI.Box(Rect(Screen.width/2, Screen.height/2, 100, 200, "Are you sure?", confirmMenu));
             selGridInt2 = GUI.SelectionGrid (Rect (Screen.width/2, Screen.height/2, 75, 25), selGridInt2, selStrings2, 2, customButton);
             if(selGridInt2 == 1){
                 Application.LoadLevel(Application.loadedLevel);
             }
             
             //if(selGridInt2 != 1||0){
                 //System.Diagnostics.Process.GetCurrentProcess().Kill();
             //}
         }
 }
Comment
Add comment · Show 14
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 Benproductions1 · Oct 22, 2013 at 12:42 AM 0
Share

Is it the same with both grids? Does the mouse over effect still appear?

avatar image Paul Ferris · Oct 22, 2013 at 07:52 AM 0
Share

Yes (to the first question) and no (to the second).

avatar image pako · Oct 22, 2013 at 08:01 AM 0
Share

Not sure if this works (just an idea): In GUI.SelectionGrid the selGridInt parameter is "The index of the selected grid button". Since it represents an index it might be internally clamped. So, your initial value of -1 might not work (an index must be >= 0). If you set the initial value of selGridInt to 0 does it make any difference?

avatar image Paul Ferris · Oct 22, 2013 at 08:42 AM 0
Share

No. Changing the value doesn't seem to affect the result.

avatar image Bunny83 · Oct 22, 2013 at 11:40 AM 1
Share

:D The IT Crowd (but you don't get an upvote since it's pointless for the question and we're not Youtube or Facebook.)

Show more comments

1 Reply

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

Answer by pako · Oct 22, 2013 at 09:42 AM

I made a test scene and copied your code. I also created dummy scenes "gameDemo" and "Multiplayer" and added them to the build settings. I changed line 29 to load the Multiplayer scene.

Well, it all works on my machine. The scenes open as expected, the options open as expected, and the Yes/No buttons of the options work as expected. So, it's not a problem with the code. Maybe there's something wrong with the input. Probably your mouse isn't detected for some reason.

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

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

How can stop the repeat random number (Random.Range) 2 Answers

Problems making character hang on walls 0 Answers

Cannot Destroy() object, created via GameObject.CreatePrimitive (others destroyed as should) 1 Answer

[Solved]Label is not a member of GUI anymore. 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