• 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 torch2424 · Aug 02, 2014 at 07:58 AM · c#guitexture

Gui.DrawTexture Working in Scene Mode, but not build or full game scene

Hello, I just started using Unity a couple of days ago, and I t$$anonymous$$nk I'm starting to get the hang of it, but not really.

Anyways, I've created t$$anonymous$$s script to fade my scenes in and out, and it works when I preview the scene, but not when I build the game, or when I preview the game as a whole in the editor.

Here's my C# script:

 //t$$anonymous$$s is our boolean to control when we want to fade out
     public static bool nextScene;
 
     public float duration = 0.5f;
 
     //our actual texture
     public Texture image;
 
 
     //create our GUI so that it will always draw on top
     void OnGUI () {
                 //draw above our other guis
                 GUI.depth = 0;
                 fadeIn ();
                 //now create our gui texture
                 GUI.DrawTexture (new Rect (0, 0, Screen.width, Screen.height),
                                      image);
         }
 
     // Use t$$anonymous$$s for initialization
     void Start () 
     {
         nextScene = false;
     }
     
     // Update is called once per frame
     void Update () 
     {
         if (nextScene) {
             fadeOut ();
                 }
     }
 
     //function for fading in
     void fadeIn(){
         GUI.color = Color.Lerp(Color.black, Color.clear, Time.time * duration);
     }
 
     //function for fading out
 
            void fadeOut(){
         GUI.color = Color.Lerp(Color.clear, Color.black, Time.time * duration);
         }

any help is appreciated, as I've been trying to figure t$$anonymous$$s out for a w$$anonymous$$le. Thank you!

Comment

People who like this

0 Show 1
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 lukas_balaz · Aug 02, 2014 at 08:18 AM 0
Share

Try load image in scrirpt. Move image to Assets/Resources folder and then add this to Start function:

 image = Resources.Load("image_name.jpg",typeof(Texture)) as Texture;

2 Replies

· Add your reply
  • Sort: 
avatar image

Answer by LSPressWorks · Aug 02, 2014 at 08:53 AM

I had the same issue, try setting your render path in the build options to vertex lit and see if that helps. Worked for me even after changing it back to forward.

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
avatar image

Answer by MvNimwegen · Sep 10, 2021 at 12:30 PM

Set your methods to public, or add an obfuscation attribute. Upon building, these methods names get obfuscated. Since Unity finds these methods through Reflection, it does not run those methods anymore.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

GUI Style Issue-- Texture not changing 2 Answers

How can i show number of lives as image during gameplay 1 Answer

Textures changing for no reason 0 Answers

Multiple Cars not working 1 Answer

How to gradient-wise fill a bitmap programmatically 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