- Home /
UI image fill origin from center?
I'm wondering if there's a way to set the fill origin of a UI image at the center. For example I'm trying to make my UI image in my game fill as something charges up so as it charges, the image appears more, but I can only make it fill from the top, bottom, left or right sides of the screen with the fill method being vertical, horizontal,radial etc. Is there some way to set the fill origin of a UI image to the center?
Answer by $$anonymous$$ · Mar 16, 2017 at 09:55 AM
I fixed this by working around it.
Simply cut your image in half and setup two images side to side half the width of your original image. Then set one as 'left' and one as 'right' and reduce both at the same time.
Answer by ahung89 · Feb 16, 2017 at 01:53 PM
Kind of a late answer, but I was able to achieve this affect by using a stencil buffer. Basically I animate a growing transparent rectagular image that has a shader on it that writes to a stencil buffer (so if you want to fill from the middle outwards vertically, you'd scale the height... if you want to do it horizontally, you'd scale width.. or you could scale both if you want the fill to happen as a square). The UI element that I want to fill has a shader that only renders when a certain value is present in the stencil buffer.
Your answer
![](https://koobas.hobune.stream/wayback/20220612051102im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Pixels Per Unit good practice query 0 Answers
Importing Error From 3D Max 1 Answer
Blender mesh reverts to original position when starting game 4 Answers
Animation playing without being called on any script 2 Answers
Import .txt and make vector3 array 2 Answers