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 Iv4etooo · Sep 05, 2014 at 09:28 PM · guiandoidgui layout

GUI elements not showing in Android and Web player

Hello everyone! The problem I have is that no GUI element shows when I test my app in Web player and on an Android device. It all works fine in Unity itself. When I select Windows platform and press Build and Run it all works great, but when I only build it and after that start the exe file all GUI elements dont't show again. To be precise, I have a script in which some GUILayout elements are defined. I also tried with GUI.Label and it was the same situation. I have defined 2 GUIStyle elements which I use for buttons styles. They had some styling like font color, texture and size. At this moment they are all black, without textures and borders, the font is with normal style and using default size. It still doesn't work.

Edit: I tried adding GUI text element from GameObject -> Create other -> GUI text and is shows in all players. So I still think the problem is with the GUIStyle, but I don't know exactly what is wrong.

This is my code:

 public class MainMenu : MonoBehaviour {
     
     float standartButtonHeight = Screen.height/10;
     float minButtonHeight = 10;
     float itemButtonHeight;
     float itemButtonWidth = Screen.width;
     bool showMenuItems = false;
     bool showMenuButton = true;
     bool showMuseumsMenu = false;
     bool showChurchesMenu = false;
     bool showMemorialsMenu = false;
     bool showStreetsMenu = false;
     bool showOtherMenu = false;
 
     public GUIStyle mainButtonStyle;
     public GUIStyle buttonStyle_2;
 
     void OnGUI()
     {    
         
         if (standartButtonHeight < minButtonHeight)
         {
             itemButtonHeight = minButtonHeight;
         } else 
             {
             itemButtonHeight = standartButtonHeight;
             }
 
         if(showMenuButton)
         {
             if (GUI.Button (new Rect (0, 0, itemButtonWidth/3, itemButtonHeight), "Menu", buttonStyle_2)) 
             {
                 showMenuButton = false;
                 showMenuItems = true;
             }
         }
         ShowMainMenu ();    
         MuseumsMenu ();
         ChurchesMenu();
 
     }
 
     void ShowMainMenu()
     {
         if(showMenuItems)
         {            
             GUILayout.BeginVertical();
             
             GUILayout.Button ("About Sofia", buttonStyle_2, GUILayout.Width(itemButtonWidth), GUILayout.Height(itemButtonHeight));
             if (GUILayout.Button ("Museums", buttonStyle_2, GUILayout.Width(itemButtonWidth), GUILayout.Height(itemButtonHeight)))
             {
                 showMuseumsMenu = true;
                 showMenuItems = false;
                 MuseumsMenu();
 
             }
             
             //few more buttons defined in the same way
             
 if (GUILayout.Button ("Exit", buttonStyle_2))
             {
                 Application.Quit();
             }
             GUILayout.EndVertical();
             
         }
 
 
 
     }

Comment
Add comment
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

1 Reply

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

Answer by Iv4etooo · Sep 06, 2014 at 02:10 PM

I figured it out - the problem was with a reading XML function, which I use in the same class, and it somehow was stopping all GUI elements to show up. I created a separate class for reading XML data and attached it to another game object. Then, in MainMenu class I added a reference to the other game object and now everything works fine.

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

2 People are following this question.

avatar image avatar image

Related Questions

Unity GUI Layout and buttons wont show up 2 Answers

What is a good component to use for a GUI inventory display? 1 Answer

Make GUI bigger and another font? 2 Answers

GUI texture size doesn't match control set with the same size 1 Answer

Unity Freezes when Loading GUI 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