1
\$\begingroup\$

Imagine a long cube, like a bar, that has a dark material, and you want to animate changing its material to a light material, but do it gradually from one end to the other, like filling up a tube, or like a progress bar that fills from one end to the other.
Is there a way to achieve this in Unity?
Or do you need to generate the animations in Blender or similar and control them in unity?

\$\endgroup\$
  • \$\begingroup\$ Do you want this to happen with GUI? \$\endgroup\$ – Vadim Tatarnikov Jun 6 '16 at 8:14
  • \$\begingroup\$ No, Unless you can use 3d meshes with GUI? I don't want to make an actual progress bar, I want to create the same effect of something filling up, with arbitrary 3d meshes. \$\endgroup\$ – Ali Jun 6 '16 at 10:17
  • \$\begingroup\$ Maybe you could do that with a custom shader which takes two (sets of) textures and then programmatically decides which one to use for each pixel. \$\endgroup\$ – Philipp Jun 6 '16 at 11:10
  • \$\begingroup\$ Yeah, shaders could be the answer, but I have never taken the time to learn how to write one. Maybe it's time. Don't know if you can pass two material to a shader though. But I guess you can "animate" the brightness and color and other properties of one texture to get a satisfactory "progress" effect I am looking for. \$\endgroup\$ – Ali Jun 6 '16 at 11:25
1
\$\begingroup\$

Hey what you can do is make a large texture with half dark and another smooth transition to bright, then zoom up on the dark area and simply change the horizontal (x) offset to gradually move in the bright part of the texture, this method should be pretty simple and effective as well as easy to do vie script.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.