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
-1
Question by TomMakesGames · Apr 26, 2013 at 06:21 PM · guiprefabmenufade

Can I get a prefab to render in front of GUI buttons created in script?

I just want to do a fade to white between a menu button click and the level load.

So I'm using a flat 2x2px white texture as a prefab and resizing it using a script on instantiation.

I can get the white fade to render in front of statically placed objects (by playing with Z transform values), but my menu buttons are still showing over the fade.

Any way to get the white fade in to also cover the scripted menu buttons? Hope my explanation is clear.

Cheers.

Comment
Add comment · Show 6
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 biohazard2u · Apr 26, 2013 at 06:27 PM 0
Share

You could hide the buttons.

avatar image biohazard2u · Apr 26, 2013 at 06:53 PM 0
Share

Put your GUI objects inside an empty Game Object, then, attach following C# script to it:

 public class TurnButtonsOnOFF : $$anonymous$$onoBehaviour {
 
     void Start () {
         turnChildrenOn();        
     }
     
     void turnChildrenOn () {
         foreach (Transform child in transform) {
             child.gameObject.SetActiveRecursively(true);
         }
     }
     
     void turnChildrenOff () {
         foreach (Transform child in transform) {
             child.gameObject.SetActiveRecursively(false);
         }    
     }    
 }

Now, manually disable the buttons object in the inspector.

That way, whenever you want to hide the buttons, all you have to do is call the script function turnChildrenOff, and vice versa.

avatar image Eric5h5 · Apr 26, 2013 at 07:17 PM 0
Share

The question is about OnGUI code, not game objects. It also wouldn't look good if you just turned the buttons off before fading to white.

avatar image biohazard2u · Apr 26, 2013 at 07:26 PM 0
Share

Any OnGui code has to go in a GameObject... If you don’t want to turn them off, you can modify their alpha. Perhaps adding a Guistyle and changing the alpha value on normal/hover... :)

avatar image Eric5h5 · Apr 26, 2013 at 07:35 PM 0
Share

Or just use DrawTexture, as I mentioned in my answer. Also you can just use GUI.color to change alpha, you don't need to add styles or anything.

Show more comments

1 Reply

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

Answer by Eric5h5 · Apr 26, 2013 at 06:41 PM

3D objects can never appear in front of OnGUI. Either don't use OnGUI, or else do the fade using OnGUI also (such as GUI.DrawTexture).

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

14 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

Related Questions

FadeIn/FadeOut GUI Menu and Text 1 Answer

HighScore analytics 0 Answers

Loading scene from WP8 menu 1 Answer

I have been struggling with a GUI texture for over a week now. What am I doing wrong? 1 Answer

GUI not work after building 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