• 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
Question by crazywiz · Jul 08, 2014 at 11:18 AM · guiwebplayermaconguimacosx

Most Gui elements do not appear on Mac Os WebPlayer

Hello,

I have a gui menu that does not appear on Mac Os WebPlayer although when i run the build on Windows it appears perfectly, same in unity editor. Basically i have a few Gui.BeginGroup - Gui.EndGroup with some DrawTexture and Gui Buttons. What is the difference between them? I create the build on a windows 7 x64 system. here is my code void OnGUI () { //drawer gui group GUI.BeginGroup (new Rect (drawerLeft, menuBarHeight, drawerWidth, Screen.height - menuBarHeight));

                 //background texture
                 GUI.DrawTexture (new Rect (0, 0, drawerWidth - btnDrawer.width + btnDrawerPadding, drawerTextBckgrndHeight - menuBarHeight), drawerTextBckgrnd);
                 GUI.DrawTexture (new Rect (0, drawerTextBckgrndHeight - menuBarHeight, drawerWidth - btnDrawer.width + btnDrawerPadding,
                                                  drawerVideoBckgrndHeight), drawerVideoBckgrnd);
                 //movie texture
                 GUI.DrawTexture (movieRect, mCurrentMovie);
                     
                 //text display
                 GUI.Label (new Rect (titleMarginLeft, titleMarginTop, drawerWidth - btnDrawer.width - titleMarginLeft * 3, 
                                  titleMarginTop), drawerTitle, drawerTitleStyle);
                 GUI.Label (new Rect (titleMarginLeft, titleMarginTop * 4, drawerWidth - btnDrawer.width - titleMarginLeft * 3, 
                                  drawerTextBckgrndHeight - menuBarHeight - titleMarginTop * 4), drawerText, drawerTextStyle);
                 //drawer button
                 if (GUI.Button (new Rect (drawerWidth - btnDrawer.width, Screen.height / 2 - btnDrawer.height / 2, 
                                     btnDrawer.width, btnDrawer.height), btnDrawer, btnDrawerStyle)) {
                         drawerLerpTimerStart = 0;
                         if (drawerShouldLerp) {
                                 drawerShouldLerp = false;
                                 drawerShouldLerpBack = true;
                         } else if (drawerShouldLerpBack) {
                                 drawerShouldLerp = true;
                                 drawerShouldLerpBack = false;
                                 mCurrentMovie.Stop ();
                                 shouldInitVideo = true;
                                 videoInitStartTime = Time.time;
                         } else if (!drawerShouldLerpBack && !drawerShouldLerp) {
                                 drawerShouldLerp = true;
                                 drawerShouldLerpBack = false;
                                 mCurrentMovie.Stop ();
                                 shouldInitVideo = true;
                                 videoInitStartTime = Time.time;
                         }
                 }
 
                 GUI.EndGroup ();
 
                 // gui menu bar
                 currentGuiElementLeft = 0;
                 GUI.DrawTexture (new Rect (0.0f, 0.0f, Screen.width, menuBarHeight + menuBackgroundFadeHeight), menuBckgrnd);
                 GUI.BeginGroup (new Rect (0.0f, 0.0f, Screen.width, menuBarHeight + menuBackgroundFadeHeight - 1.0f));
                 //background texture
                 GUI.DrawTexture (new Rect (0.0f, 0.0f, Screen.width, menuBarHeight + menuBackgroundFadeHeight), menuBckgrnd);
                 GUI.Label (new Rect (menuLogoLeft, menuLogoTop, menuLogoWidth, menuLogoHeight), new GUIContent ("CitoPress", menuLogo), logoStyle);
                 //help button
                 currentGuiElementLeft = Screen.width - btnMenuWidth;
                 if (GUI.Button (new Rect (currentGuiElementLeft, 0, btnMenuWidth, btnMenuHeight), "", btnMenuHelpStyle)) {
                     shouldRenderHelp=true;
                 }
                 currentGuiElementLeft -= menuDivider.width;
                 GUI.DrawTexture (new Rect (currentGuiElementLeft, 0, menuDivider.width, btnMenuHeight), menuDivider);
 
                 //zoom button
                 currentGuiElementLeft -= btnMenuWidth;
                 if (GUI.Button (new Rect (currentGuiElementLeft, 0, btnMenuWidth, btnMenuHeight), "", btnMenuZoomStyle)) {
                         if (shouldShowBulletZoomBar) {
                                 shouldShowBulletZoomBar = false;
                                 btnMenuZoomStyle.normal.background = (Texture2D)Resources.Load ("meta/toggle_zoom"); 
                         } else {
                                 shouldShowBulletZoomBar = true;
                                 btnMenuZoomStyle.normal.background = (Texture2D)Resources.Load ("meta/toggle_zoom_pressed"); 
                         }
                 }
                 currentGuiElementLeft -= menuDivider.width;
                 GUI.DrawTexture (new Rect (currentGuiElementLeft, 0, menuDivider.width, btnMenuHeight), menuDivider);
                 //language button
                 currentGuiElementLeft -= btnMenuWidth;
                 if (GUI.Button (new Rect (currentGuiElementLeft, 0, btnMenuWidth, btnMenuHeight), "", btnMenuLanguageStyle)) {
                         shouldRenderLangSelection = true;
                 }
                 currentGuiElementLeft -= menuDivider.width;
                 GUI.DrawTexture (new Rect (currentGuiElementLeft, 0, menuDivider.width, btnMenuHeight), menuDivider);
 
                 // enable/disable hotspot texts
                 currentGuiElementLeft -= btnMenuWidth * 2;
                 if (GUI.Button (new Rect (currentGuiElementLeft, 0, btnMenuWidth * 2, btnMenuHeight), "", btnMenuHotSpotsTextStyle)) {
                         textLerpTimerStart = 0;
                         if (shouldShowBulletTexts) {
                                 shouldShowBulletTexts = false;
                                 btnMenuHotSpotsTextStyle.normal.background = (Texture2D)Resources.Load ("meta/toggle_text_off"); 
                         } else {
                                 shouldShowBulletTexts = true;
                                 btnMenuHotSpotsTextStyle.normal.background = (Texture2D)Resources.Load ("meta/toggle_text_on"); 
                         }
                 }
                 currentGuiElementLeft -= menuDivider.width;
                 GUI.DrawTexture (new Rect (currentGuiElementLeft, 0, menuDivider.width, btnMenuHeight), menuDivider);
                 // enable/disable hotspots
                 currentGuiElementLeft -= btnMenuWidth;
                 if (GUI.Button (new Rect (currentGuiElementLeft, 0, btnMenuWidth, btnMenuHeight), "", btnMenuHotSpotsStyle)) {
                         if (shouldShowBullets) {
                                 shouldShowBullets = false;
                                 for (int i=0; i<bullets.Length; i++) {
                                         bullets [i].SetActive (false);
                                 }
                         } else {
                                 shouldShowBullets = true;
                                 for (int i=0; i<bullets.Length; i++) {
                                         bullets [i].SetActive (true);
                                 }
 
                         }
                 }
                 currentGuiElementLeft -= menuDivider.width;
                 GUI.DrawTexture (new Rect (currentGuiElementLeft, 0, menuDivider.width, btnMenuHeight), menuDivider);
                 //reset button
                 currentGuiElementLeft -= btnMenuWidth;
                 if (GUI.Button (new Rect (currentGuiElementLeft, 0, btnMenuWidth, btnMenuHeight), "", btnMenuResetStyle)) {
                         Application.LoadLevel (Application.loadedLevel);
                 }
                 GUI.EndGroup ();
                 //render zoom scrollbar
                 if (shouldShowBulletZoomBar) {
                         Camera.main.fieldOfView = GUI.VerticalSlider (new Rect (Screen.width - zoomBarRightMargin,
                                                                   zoomBarTopMargin, zoomBarWidth, Screen.height - zoomBarTopMargin), 
                                                          Camera.main.fieldOfView, 120.0f, 15.0f, zoomBarSliderStyle, zoomBarThumbStyle);
                 }
 
                 //language selection GUI
                 if (shouldRenderLangSelection) {
                         GUI.BeginGroup (new Rect (0.0f, 0.0f, Screen.width, Screen.height), helpBackground);
                         if (GUI.Button (new Rect (Screen.width * 0.5f - helpEnglish.width * 2 - helpLanguageSpacing * 1.5f, 
                                   Screen.height * 0.5f - helpEnglish.height * 0.5f, helpEnglish.width, helpEnglish.height), new GUIContent ("English", helpEnglish), helpLanguageStyle)) {
                                 shouldRenderLangSelection = false;
                                 mLangStrings = new MultiLanguageScript ("English");
                                 reloadTexts ();
                         }
                         if (GUI.Button (new Rect (Screen.width * 0.5f - helpEnglish.width - helpLanguageSpacing * 0.5f, 
                                       Screen.height * 0.5f - helpEnglish.height * 0.5f, helpEnglish.width, helpEnglish.height), new GUIContent ("Deutsch", helpGerman), helpLanguageStyle)) {
                                 shouldRenderLangSelection = false;
                                 mLangStrings = new MultiLanguageScript ("German");
                                 reloadTexts ();    
                         }
                         if (GUI.Button (new Rect (Screen.width * 0.5f + helpLanguageSpacing * 0.5f, 
                                       Screen.height * 0.5f - helpEnglish.height * 0.5f, helpEnglish.width, helpEnglish.height), new GUIContent ("Francais", helpFrench), helpLanguageStyle)) {
                                 shouldRenderLangSelection = false;
                                 mLangStrings = new MultiLanguageScript ("French");
                                 reloadTexts ();
                         }
                         if (GUI.Button (new Rect (Screen.width * 0.5f + helpEnglish.width + helpLanguageSpacing * 1.5f, 
                                       Screen.height * 0.5f - helpEnglish.height * 0.5f, helpEnglish.width, helpEnglish.height), new GUIContent ("Chinese", helpChinese), helpLanguageStyle)) {
                                 shouldRenderLangSelection = false;
                                 mLangStrings = new MultiLanguageScript ("Japanese");
                                 reloadTexts ();
                         }
                         GUI.EndGroup ();
                 }
         
             
 
 
                 //drawer open/close animation
                 if (drawerShouldLerp) {
                         drawerLerpTimer = (drawerLerpTimerStart += Time.deltaTime) / 6;
                         drawerLeft = Mathf.SmoothStep (drawerLeft, 0, drawerLerpTimer);
                 } else if (drawerShouldLerpBack) {
                         drawerLerpTimer = (drawerLerpTimerStart += Time.deltaTime) / 6;
                         drawerLeft = Mathf.SmoothStep (drawerLeft, - drawerWidth + btnDrawer.width, drawerLerpTimer);
                 }
 
                 //show Help
             if (shouldRenderHelp) {
                 GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), menuHelp);
                 }
             
                 //fade in /out bullet text
                 if (shouldShowBulletTexts) {
                         textLerpTimer = (textLerpTimerStart += Time.deltaTime) / 3;
                         for (int i=0; i<bullets.Length; i++) {
                                 Color tempColor = bullets [i].guiText.material.color;
                                 tempColor.a = Mathf.Lerp (0.0f, 1.0f, textLerpTimer);
                                 bullets [i].guiText.material.color = tempColor;
                                 tempColor = bulletBacks [i].guiTexture.color;
                                 tempColor.a = Mathf.Lerp (0.0f, 1.0f, textLerpTimer);
                                 bulletBacks [i].guiTexture.color = tempColor;
                         }
 
                 } else {
                         textLerpTimer = (textLerpTimerStart += Time.deltaTime) / 3;
                         for (int i=0; i<bullets.Length; i++) {
                                 //                Fade.use.Alpha(bullets[i], 1.0f, 0.0f, 1.0f);
                                 Color tempColor = bullets [i].guiText.material.color;
                                 tempColor.a = Mathf.Lerp (1.0f, 0.0f, textLerpTimer);
                                 bullets [i].guiText.material.color = tempColor;
                 
                                 tempColor = bulletBacks [i].guiTexture.color;
                                 tempColor.a = Mathf.Lerp (1.0f, 0.0f, textLerpTimer);
                                 bulletBacks [i].guiTexture.color = tempColor;
                         }
                 }
         }

Please note that the "//Drawer button" appears correctly on Mac Os too, and the "//text display" appears in the top left corner (although at launch they should be outside the screen in the left) I have looked everywhere on the forum but i couldn't find a solution or a similar issue with an answer.

Any advice is much appreciated

Comment

People who like this

0 Show 0
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
Best Answer

Answer by crazywiz · Jul 08, 2014 at 03:44 PM

Finally Fixed it, it seems to be part unity issue with code run order. On windows apparently Screen canvas is initialized first so you can declare global variables in your script like: "private float drawerWidth = Screen.width *0.05f; ". On Mac OS apparently they initialize my variables before initializing the Screen Canvas so Screen.width is zero when assigning my variables. Anyway hope this helps someone else. PS: the solution was to declare the variables globally and assign their values in onStart()

Comment

People who like this

0 Show 0 · 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Missing characters in Mac webplayer - Font/GUI issue? 0 Answers

Steam Overlay causing GUI graphics to glitch in Unity game on OSX. 2 Answers

unity wont appear as installed on mac 0 Answers

Web player performance problem on MAC OS X 3 Answers

Render particles to forground with script 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