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 Allan · Nov 03, 2010 at 10:51 AM · guitextfadetiming

Guitext fade in/out timing with trigger?

Hi, I'm a real newbie with unity and JS in general so I apologise if this question has already been asked in a more professional form.

I'm creating a interactive narrative for a uni project with unity, and one of the elements of the experience is that when the player walks into a certain zone, narrative elements would fade in.

I am currently achieving this through triggers and fade in/out script on guitext.

However, I'm trying to get somewhat of a dialogue effect happening so guiText.text changes after a few seconds.

I'm running into a serious issue where if the player walks in and out repeatly of a trigger, the fade in/out effects start stacking up (as I'm using yield WaitForSeconds) and I get a really annoying flashing effect on the guitext.

I'm sure theres a much better way of doing this but I've been trying to get around it through if statements and what not but all I seem to do is make it worse...

Here's a example

var sayWhat = 1;

function OnTriggerEnter (collision : Collider) { if(collision.gameObject.tag == "Player"){ if(sayWhat == 1){ staticText2.TEXT = "Hmmm...?"; staticText2.FadeIN = true; yield WaitForSeconds(2); staticText2.FadeOUT = true; sayWhat = 2; }if(sayWhat == 2){ staticText2.TEXT = "I hear something..."; staticText2.FadeIN = true; yield WaitForSeconds(2); staticText2.FadeOUT = true; } } }

function OnTriggerExit (collision : Collider) {

 if(collision.gameObject.tag == "Player"){
     staticText2.FadeOUT = true;
 }

}

and on the guitext's I have:

static var TEXT : String; static var FadeIN = false; static var FadeOUT = false;

function Update(){ guiText.text = TEXT; if (FadeIN == true) { FadeIn(); FadeIN = false; }else if (FadeOUT == true){ FadeOut(); FadeOUT = false; } }

function FadeIn(){

  Fade.use.Alpha(guiText.material, 0.0, 1.0, 1.0, EaseType.In);
 }

function FadeOut(){ Fade.use.Alpha(guiText.material, 1.0, 0.0, 1.0, EaseType.Out); }

It's okay when I have a few sentences but once I have a few it starts being really annoying...I have a feeling I'm TOTALLY going about this wrong way...so it would be great if someone could point me towards the right direction....Thanks in advance!!!

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

0 Replies

· Add your reply
  • Sort: 

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

No one has followed this question yet.

Related Questions

How do I repeat a part of my script? 2 Answers

Gui Pop-Up Notification for Picking up Items 1 Answer

Text size / position / fade in code 2 Answers

Fade in and out a GUIText pressing another GUItext? 1 Answer

Display GUI when kill count reaches 5 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