• 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 Nercoe · Feb 28, 2013 at 08:31 PM · gameobject2dtexture

Keeping a specific GameObject infront of Texture2D?

Hi guys, just wondering if there is a way to get a single object (not all objects) in front of my Texture2D. My scene fades out, I want everything to fade out apart from the character, is there any documentation you guys could point me to in order to aid me in achieving this effect? Would it be possible for me to implement it into this script?

 public var fadeOutTexture : Texture2D;
 public var fadeSpeed = 2.0;
  
 var drawDepth = -1000;
 
 private var alpha = 1.0; 
  
 private var fadeDir = -1;
 
 function OnGUI(){
  
     alpha += fadeDir * fadeSpeed * Time.deltaTime;    
     alpha = Mathf.Clamp01(alpha);    
  
     GUI.color.a = alpha;
  
     GUI.depth = drawDepth;
  
     GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), fadeOutTexture);
     
 }
 
 function fadeIn(){
     fadeDir = -1;    
 }
  
  
 function fadeOut(){
     fadeDir = 1;    
 }
  
 function Start(){
     alpha=1;
     fadeIn();
 }

That works,but is what I want possible?

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

1 Reply

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

Answer by GC1983 · Feb 28, 2013 at 08:54 PM

You cant place 3D objects in front of GUI. Its not designed to. GUI is built to be placed on the screen like you are looking through a window and all the 3D objects are the viewed on the other side of it. The only way you could make it work the way you want would be to simulate the GUI design through texturing 3D objects and make them look and act like GUI.

Comment
Add comment · Show 4 · 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 Nercoe · Feb 28, 2013 at 09:00 PM 0
Share

I thought that may be the case, fading objects out is ok though isn't it? I think I've seen this somewhere, I could implement this if it's possible.

avatar image GC1983 · Feb 28, 2013 at 09:14 PM 0
Share

Yes. You have to be sure the shader is on the correct setting for transparency. Go down the list and look for Transparent. In the colors channel, you can adjust the alpha on the bottom of the list.

There are a ton of topics on alpha fading. Here's a good one:

http://answers.unity3d.com/questions/27128/fading-an-objects-opacity-over-time-via-script.html

avatar image Nercoe · Feb 28, 2013 at 09:19 PM 0
Share

Thanks a bunch man, highly appreciate your time :)

avatar image GC1983 · Feb 28, 2013 at 11:02 PM 0
Share

No Problem!

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

10 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

Related Questions

using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers

How to assign multiple popup textures to game objects 1 Answer

How do you place an image on an object so that the object size is based on pixels per unit and image size? 1 Answer

get the gameobject's variable 1 Answer

My ship destroyed when i press fire 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