A
A
Alex Kolyhov2020-07-29 21:51:08
Unity
Alex Kolyhov, 2020-07-29 21:51:08

How to make an immutable Slider in Unity?

In my game, the health bar is implemented using the Slider UI component, but I have one problem: the Fill in the Slider can be moved. Although in my code I wrote in FixedUpdate that: slider.value = hp; but you can still move it evenly, although it immediately returns to its place, but still, it does not look very good. Please tell me how to fix this?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GavriKos, 2020-07-29
@Alex_Kolyhov

Don't use slider for this, that's all. A progress bar can be made from an Image - it has a Filled fill type.
If you really want a slider - then chop off everything that can catch a click there - remove the Raycast Target from all Image. If this does not help - a mega-crutch - put a transparent image on top, let it catch clicks.

M
Manheten, 2021-06-03
@Manheten

I know it's late, but in order not to change, you need to disable the first checkbox60b91146a5dcf553152990.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question