• 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 /
  • Help Room /
avatar image
Question by ma22be61 · Jan 14, 2016 at 06:24 PM · uibuttonimageui imagefill

Managing multiple images fillamount by one function?

I want to fill the button that I clicked but when I click multiple buttons the button that I clicked before stops and the other button starts.

That's the script :

 public function ActionTime (actionSeconds : float) 
 {
 actionTime = actionSeconds;
 actionTimeComplete = actionSeconds;
 
 }
 
 //COOLDOWN IMAGES
 public function CooldownImage (imageForCooldown : Image)
 {
 imageCooldown = imageForCooldown;
 CooldownFunction();
 }
 
 public function CooldownFunction ()
 {
 var actionTime = 0f;
 imageCooldown.fillAmount=actionTime;
 imageCooldown.GetComponent(Button).interactable = false;
 
 while(actionTime < actionTimeComplete )
 {
 actionTime += Time.deltaTime;
 imageCooldown.fillAmount=actionTime/actionTimeComplete;
 yield;
 }
 moneyGlobal+=moneyToGive;
 XPGlobal+=xpToGive;
 imageCooldown.GetComponent(Button).interactable = true;
 }
 

Everything works fine until I click another button. Basically that script can complete one image fillamount at once , how can I manage to complete multiple images without creating a bunch of functions?

Comment

People who like this

0 Show 1
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 ma22be61 · Jan 15, 2016 at 05:56 PM 0
Share

Any advice much appreciated

1 Reply

  • Sort: 
avatar image
Best Answer

Answer by ma22be61 · Jan 22, 2016 at 05:56 PM

Nevermind.

I got it. It was simpler than I tought.

Comment

People who like this

0 Show 0 · 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

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta on June 13. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

38 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

Why can't spam click on UI Image ? 0 Answers

How to have get button display a raw image? 3 Answers

button ui becomes active by click outside the button in exe file!!(unity 5.1) 1 Answer

Canvas Image UV change on play mode (Shader Lab) 0 Answers

Change sprite of a UI image throug button click (c#) 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