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
1
Question by SirBedlam · Jul 14, 2012 at 11:47 PM · triggervariableguitexturefade

How to fade between 3 GUI textures?

I've looked at many GUI texture fading scripts, but I can't seem to alter them to work how I want them to. I have 3 GUI textures, and a variable I need them to work with.

  • As soon as the game starts, the first GUI texture is displayed, and stays on screen.

  • When the "anxiety" variable is above 10, the first texture fades out, as the second one fades in.

  • When the anxiety variable reaches above 20, the second texture fades out, as the third one fades in.

This seems so simple, but I can't get it to work! Can someone please give me a hand here? I'm using Java.

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 aldonaletto · Jul 15, 2012 at 01:20 AM

If you're using GUITextures, you must have 3 of them (one for each texture) and control the individual guiTexture.color.a values - 0 is invisible, 1 is fully visible. You could define limits where the crossfade occurs, and create AnimationCurves to control each texture - like this:

var anxiety: float = 10; // your anxiety variable var gTex1: GUITexture; // drag the first texture here var gTex2: GUITexture; // drag the 2nd here var gTex3: GUITexture; // drag the 3rd here var lim12: float = 10; // 1st to 2nd limit var lim23: float = 20; // 2nd to 3rd limit var crossRange: float = 5; // crossfade range

public var alpha1: AnimationCurve; public var alpha2: AnimationCurve; public var alpha3: AnimationCurve;

function Start(){ var margin = crossRange/2; // find the necessary curve points: var v1 = lim12-margin; var v2 = lim12+margin; var v3 = lim23-margin; var v4 = lim23+margin; // create curves for each texture: alpha1 = AnimationCurve(Keyframe(0,1), Keyframe(v1,1), Keyframe(v2,0)); alpha2 = AnimationCurve(Keyframe(v1,0), Keyframe(v2,1), Keyframe(v3,1), Keyframe(v4,0)); alpha3 = AnimationCurve(Keyframe(0,0), Keyframe(v3,0), Keyframe(v4,1)); }

function Update(){ gTex1.color.a = alpha1.Evaluate(anxiety); gTex2.color.a = alpha2.Evaluate(anxiety); gTex3.color.a = alpha3.Evaluate(anxiety); }

Comment
Add comment · Show 1 · 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 SirBedlam · Jul 15, 2012 at 03:41 AM 0
Share

Thank you, that worked beautifully! I really appreciate it!

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

Getting a Trigger's parent 1 Answer

GUItexture displayed after al triggers activated 1 Answer

How to fade in onGUI on trigger enter/exit? Gui shows on trigger, but no fade. 1 Answer

making a variable (var) false when not colliding with a trigger. 1 Answer

GUITextures and Triggers 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