• 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 MasonicGryphon7 · Apr 19, 2013 at 02:25 PM · damageimage effectsfade out

Fade out Image Effects?

Hi! I was wondering if there is a possibility to fade out an image effect. Example: I have a script where the player gets his then this image effect will show up and then fade out after 2 or 4 seconds. BTW: I already have a script that shows a texture when the player gets damaged. I want to change it to an Image Effect, example: Grayscale Effect.

Is that possible? Thanks :D

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 Lockstep · Apr 19, 2013 at 04:26 PM

Best solution imho is using a GUITexture. Simply interpolate the alpha value of the GUITextures color property. Code could look like this(C# but js would work basically the same):

 public GUITexture _myTexture;    //The guiTexture you want to manipulate. Set this up in the inspector.
 public float stayTime = 2f;   // Time before fading starts
 public float fadeTime = 2f;   // How long we want to fade
 private float lastStartTime = -100f;
 
 void Update(){
     if_myTexture.enabled == true) AnimateImage(); //Animate the texture if it is enabled
 }
 void AnimateImage(){
     float t = (Time.time - lastStartTime- stayTime)/fadeTime;
     if(t <= 1f){
         Color fullColor = Color.white;
         Color noColor = new Color(1f,1f,1f,0f);
         _myTexture.color = Color.Lerp(fullColor, noColor, t) ;
     } else {    //Once we faded out we shut the texture off, in order to save memory
         _myTexture.enabled = false;
     }
 }
 public void ShowImage(){    //Call this to start the effect
     _myTexture.enabled = true;
     lastStartTime = Time.time;
 }



Comment
Add comment · Show 5 · 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 MasonicGryphon7 · Apr 19, 2013 at 05:35 PM 0
Share

thanks! but forgot to mention that I already have the GUITexture showing up when the player takes damage. I wanted to change it to show an image effect, example the Grayscale Effect.

avatar image Lockstep · Apr 19, 2013 at 11:29 PM 0
Share

Grayscale effect, like all image effects is in the pro version only. In case you got it, just import the pro standard assets. Otherwise you are stuck with manipulating the color.

If your image only has one color (i.e. blood splatters or something), you can reimport it without color and then color it through the guitextures color property. You only need to change fullColor to Color.red (for blood)

edit: In this case you might want to make the fullColor a public varible and set it through the inspector for easier picking the right hue

avatar image MasonicGryphon7 · Apr 20, 2013 at 09:42 AM 0
Share

yup, I have the pro version of Unity. And I already have imported the pro assets in my game, and applied the grayscale effect onto the camera. Now I just want it to show when the player gets hurt and then fade away by time. I suppose you're supposed to use alpha? And btw, i dont want to use texture like blood splatter, its too original, get me? :P That's why I want to use the GrayScale Effect when the player gets hurt.

avatar image Lockstep · Apr 20, 2013 at 01:07 PM 0
Share

I think I finally get what you are trying to do. Unfortunately I don't have pro myself, so I can't really tell, but it seems you have to use ColorCorrectionCurves. Then you only need to manipulate the saturation.

avatar image MasonicGryphon7 · Apr 24, 2013 at 02:59 PM 0
Share

AH! YES! I GOT IT TO WOR$$anonymous$$! Thanks! Now I just gotta figure out on how to do it with NoiseGrain Effect ;P But thanks anyway! WOR$$anonymous$$ED!

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

12 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

Related Questions

Take health from enemy 3 Answers

Deal Damage On Collision 3 Answers

[SOLVED]Different levels of damage per particle collision 1 Answer

How to change the damage my gun does? 1 Answer

The damage to my player keeps stacking even after I quit the game and restart. 2 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