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 starvar · Apr 06, 2012 at 05:30 PM · 2dtextureseconds

2D texture for 2 seconds on screen?

Hi guys do one of you know a script so that if I have for example collected 200 coins a 2dtexture comes up and leaves after 2 seconds? ty!

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

3 Replies

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

Answer by fafase · Apr 06, 2012 at 05:51 PM

You could create a GuiTexture. Position it where you want it. Then:

 var texture : Texture2D;
 var On:boolean;
 
 function Start(){
      guiTexture.enabled = false;
 }
 
 function Update(){
   if(coins==200){
      On=true}}
   if(On){
      GuiGoesOn();}

 function GuiGoesOn(){
    On=!On;
    guiTexture.enabled=true;
    yield WaitForSeconds(2);
    guiTexture.enabled=false;
 }

Now is your coin counting in the same script? Is it a static variable?If yes, call the static with

 ScriptName.countVar

If not static, you still can send a message from the script where the counting happens. Somehow like this

in the GuiTexture script

 var texture : Texture2D;
 
 function Start(){
     guiTexture.enabled = false;
 }
 
  function GuiGoesOn(){
     guiTexture.enabled=true;
     yield WaitForSecond(2);
     guiTexture.enabled=false;
    }

In the script where coins are counted:

 function Update(){
      if(coins == 200)
      {
          On = True; 
      }
      if(On){
             gameObject.Find("TheGUItextureObject").SendMessage("GuiGoesOn");
             On=!On;
      }  
 }


I edited a little as I realized that it could work but would not be the best.

Comment
Add comment · Show 2 · 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 i2naok8 · May 18, 2013 at 04:40 PM 0
Share

Can I ask How add a random aaray of texture 2d in this script?

avatar image fafase · May 19, 2013 at 07:20 AM 0
Share

@i2naok8 I answered this issue here: http://answers.unity3d.com/questions/446328/play-random-music.html.

It is for music clip but you just need to modify it for Texture2D. If you need more info, you need to post a question on it as it is not related to this thread.

avatar image
0

Answer by santelia · Apr 06, 2012 at 05:57 PM

I'm rather newbe, but maybe using Playmaker and global variables can be a breeze.

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 TheFrankman123 · Apr 06, 2012 at 05:57 PM

Best off using a particle emitter and set it so it only fires one object and has a life of 2 seconds. Simples.

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

is it possible to make 2d real time coloring with masks (paint app) 1 Answer

Need Help - 2D Flat Ground Materials 2 Answers

Collision with Texture when alpha=1 1 Answer

Changing texture type to "Advanced" stops it from being affected when changing Quality Settings. Any way to get around this? 0 Answers

Highlighting tiles on a hexagonal grid 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