Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 alyabov · Jun 02, 2011 at 06:36 AM · fullscreendrawtextureopacity

GUI.DrawTexture with opacity

Hello! Please help me to draw the fullscreen texture with necessary level of opacity (I need to make fading animation for it).

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

4 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by Cyb3rManiak · Jun 02, 2011 at 08:24 AM

You can also alter the GUI.color (specifically GUI.color.a) right before the call to GUI.DrawTexture() to determine the transparency. Just make sure to return it to the previous color after it if you draw anything else. You can even make the entire GUI fade away, buttons and all...

This works just fine:

 using UnityEngine;
 using System.Collections;
 
 public class GUITest : MonoBehaviour 
 {
     public Texture2D     txForeground;
     public float        fAlpha;
     
     void OnGUI()
     {
         // Unless you changed it, the default for GUI.color is Color.white, but better be safe than sorry. 
         // Just save the previous color and restore it after you draw whatever you want to be transparent.
         Color colPreviousGUIColor = GUI.color;
         
         GUI.color = new Color(colPreviousGUIColor.r, colPreviousGUIColor.g, colPreviousGUIColor.b, fAlpha);
         GUI.DrawTexture(new Rect(0,0,Screen.width, Screen.height), txForeground);
         
         GUI.color = colPreviousGUIColor;
     }
 }
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 Edy · Jun 02, 2011 at 08:12 AM

You can specify the the opacity of a texture by setting each pixel's alpha value. However this is quite slow for fading animations (requires many SetPixel calls), so you'd better use a regular Plane (GameObject > Create other > Plane) in front of the camera showing the texture. You can change the transparency by setting the Alpha value for the base color (ensure to use a transparent material).

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 alyabov · Jun 02, 2011 at 08:22 AM

ОК, I'll try it. Or maybe Graphics.DrawTexture can help? It has Material and Color in parameters list. So maybe I can to change alpha channel using it?

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 alyabov · Jun 02, 2011 at 08:29 AM

Very good idea. Do this function change all GUI elements? I have 6 textures on the screen and each of them must have different opacity level.

Oh, I understand how it works. Thanks to all for help!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Opacity for DrawTexture not working 1 Answer

Can the editor play in full screen? 3 Answers

Webplayer: Switch to fullscreen via HTML-Button? 1 Answer

unity web player fatal error couldn't switch to requested monitor resolution 1 Answer

Standalone player in windows open fullscreen, but player settings says windowed 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