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 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 think I'm starting to get the hang of it, but not really.

Anyways, I've created this 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:

 //this 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 this 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 this out for a while. Thank you!

Comment
Add comment · 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. $$anonymous$$ove 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
0

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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to gradient-wise fill a bitmap programmatically 1 Answer

Equivelant of GUI.DrawSprite() ? 0 Answers

How To Print Text Random 2 Answers

Way to have a pause and play texture in same GUI texture? 0 Answers

How to change font size in ongui function 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