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
2
Question by R3K · Sep 11, 2014 at 03:44 PM · draglauncharrowbar

How can I make a textured power bar

Hi everyone,

It's a 3D game in top view (without gravity), it consists to launch a projectile from a position A, the final position of the mouse give the second point B, the vector AB is the direction of the launch and the magnitude of the vector is proportional to the power of launch.

My problem is graphic, I tried to do a textured power bar to the position of the mouse but the texture stretches and compresses depending on the size of the bar. This is a picture to be more clear

alt text

So it's possible to make it like the second picture?

illustation.jpg (15.9 kB)
Comment
Add comment · 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 Scribe · Sep 11, 2014 at 03:53 PM 0
Share

Is this an actual object or some form of GUI? If it is an object you could try changing the 'tiling' of its material to be same as the scale, so when your object is at scale 1, your texture is also scale one, at object scale 0.5, you have have 0.5 as your tiling. If it is an OnGUI setup, you can use GUI groups.

You may also wish to check out Eric's pretty famous answer for making a circular progress bar

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by TrollHachem · Sep 11, 2014 at 03:55 PM

If you're using the 4.6 Open Beta uGUI , you can make the image component's image type filled and set it to horizontal , then simply clamp your health from 0 to 1 and put the result in "Fill Amount". If you're using legacy , well i don't know :/

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 R3K · Sep 13, 2014 at 07:56 PM

Thanks for the reply

I used a cylinder for my power bar, and I applied this script to control its "y" tiling proportionaly to the scale of my bar :

renderer.material.mainTextureScale = new Vector2 (1, AB.magnitude);

a little picture to illustrate the result alt text


capture.jpg (12.0 kB)
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 TrollHachem · Sep 14, 2014 at 05:08 PM 0
Share

it'll be better to use a quad.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

"Launch" a rigidbody 3 Answers

Creating a "drop zone" for textures 1 Answer

Limit object rotation on drag it 0 Answers

Dragging an object smoothly 2 Answers

Need help debugging: SiblingIndex 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