public virtual void ForceUpdate ()
{
mIsDirty = false;
if (mFG != null)
{
UIBasicSprite sprite = mFG as UIBasicSprite;
if (isHorizontal)
{
if (sprite != null && sprite.type == UIBasicSprite.Type.Filled)
{
if (sprite.fillDirection == UIBasicSprite.FillDirection.Horizontal ||
sprite.fillDirection == UIBasicSprite.FillDirection.Vertical)
{
sprite.fillDirection = UIBasicSprite.FillDirection.Horizontal;
sprite.invert = isInverted;
}
sprite.fillAmount = value;
}
else
{
mFG.drawRegion = isInverted ?
new Vector4(1f - value, 0f, 1f, 1f) :
new Vector4(0f, 0f, value, 1f);
}
}
else if (sprite != null && sprite.type == UIBasicSprite.Type.Filled)
{
if (sprite.fillDirection == UIBasicSprite.FillDirection.Horizontal ||
sprite.fillDirection == UIBasicSprite.FillDirection.Vertical)
{
sprite.fillDirection = UIBasicSprite.FillDirection.Vertical;
sprite.invert = isInverted;
}
sprite.fillAmount = value;
}
else
{
mFG.drawRegion = isInverted ?
new Vector4(0f, 1f - value, 1f, 1f) :
new Vector4(0f, 0f, 1f, value);
}
}
if (thumb != null && (mFG != null || mBG != null))
{
Vector3[] corners = (mFG != null) ? mFG.localCorners : mBG.localCorners;
Vector4 br = (mFG != null) ? mFG.border : mBG.border;
corners[0].x += br.x;
corners[1].x += br.x;
corners[2].x -= br.z;
corners[3].x -= br.z;
corners[0].y += br.y;
corners[1].y -= br.w;
corners[2].y -= br.w;
corners[3].y += br.y;
Transform t = (mFG != null) ? mFG.cachedTransform : mBG.cachedTransform;
for (int i = 0; i < 4; ++i) corners[i] = t.TransformPoint(corners[i]);
if (isHorizontal)
{
Vector3 v0 = Vector3.Lerp(corners[0], corners[1], 0.5f);
Vector3 v1 = Vector3.Lerp(corners[2], corners[3], 0.5f);
SetThumbPosition(Vector3.Lerp(v0, v1, isInverted ? 1f - value : value));
}
else
{
Vector3 v0 = Vector3.Lerp(corners[0], corners[3], 0.5f);
Vector3 v1 = Vector3.Lerp(corners[1], corners[2], 0.5f);
SetThumbPosition(Vector3.Lerp(v0, v1, isInverted ? 1f - value : value));
}
}
}