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 AnnaVicVic · May 18, 2021 at 12:28 AM · progress bar

Want to create a moving line over a filling object

Hello!

I am new to unity and am trying to create a simple moving progress bar. I have created the progress bar that moves up and down by vertical filling. However, I want to add a black line over the moving filled area (so it matches the border, see images). Is there an easy way to make the black horizontal line move with the other object as it fills (right now the black line is just a stationary object).

Thanks! Anna

alt text alt text

capture3.jpg (21.7 kB)
capture1.jpg (22.5 kB)
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

Answer by unity_MXGApNcapNfNLg · May 18, 2021 at 11:32 AM

@AnnaVicVic Attach this script to the moving line and make moving line child of the surface (the surface will be a fill image)

 using UnityEngine;
 using UnityEngine.UI;
 public class MoveableLine : MonoBehaviour
 {
     public Image fillImage;
     public float rectHeight
     public float incrementFactor;
     void Update ()
     {
         var fillImageRect = fillImage.GetComponent<RectTransform>();
         rectHeight = fillImageRect.rect.height/2;
         incrementFactor = (fillImage.fillAmount * (fillImageRect.rect.height))- fillImageRect.rect.height/2;
         this.GetComponent<RectTransform>().localPosition=new Vector3(0, incrementFactor, 0);
     }
 }
Comment
Add comment · Show 10 · 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 AnnaVicVic · May 20, 2021 at 12:15 AM 0
Share

Thanks so much for your help, but I am getting the following error - "Assets\ManaBar\MoveableLine.cs(10,9): error CS0103: The name 'fillImageRect' does not exist in the current context" for each line it says fillImageRect. I am not much for coding, so I am not sure what is wrong. It is defined in your code.

I included another screen shot, in case the issue is my file na$$anonymous$$g.

Sorry and thanks!!

alt text

[1]: /storage/temp/180925-download.png

avatar image andrew-lukasik AnnaVicVic · May 20, 2021 at 08:17 AM 0
Share

That's my fault when editing the post. Just change fillImageRect = to var fillImageRect = (add var there)

avatar image AnnaVicVic andrew-lukasik · May 24, 2021 at 12:04 AM 0
Share

Thanks for that! It looks like you edited the original comment to include the var, so I copy and pasted the script as is above, but now I get a different error message (attached). Do you know I could try next?alt text

Show more comments

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

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

Related Questions

Best way to make an animated infinite striped progress bar? 1 Answer

Changing text color based on background to make readable 1 Answer

Simple progress bar/timer 1 Answer

Problem with WWW.progress 3 Answers

Progress Bar Display help (Bonus) 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