万年素人からHackerへの道

万年素人がHackerになれるまで殴り書きするぜ。

  • ・寄付お願いします
    YENTEN:YYzNPzdsZWqr5THWAdMrKDj7GT8ietDc2W
    BitZenny:ZfpUbVya8MWQkjjGJMjA7P9pPkqaLnwPWH
    c0ban:8KG95GXdEquNpPW8xJAJf7nn5kbimQ5wj1

NGUIのUIScrollBarのバグ?

UIScrollBarにてスクロールすると、勝手にforegroundのバーの大きさがbackground
のサイズに合わさってしまう。

このように関係ない方向が修正されないようにしたがこれでいいのか?

	public void ForceUpdate ()
	{
		mIsDirty = false;

		if (mBG != null && mFG != null)
		{
			mSize = Mathf.Clamp01(mSize);
			mScroll = Mathf.Clamp01(mScroll);

			Vector4 bg = mBG.border;
			Vector4 fg = mFG.border;

			// Space available for the background
			Vector2 bgs = new Vector2(
				Mathf.Max(0f, mBG.cachedTransform.localScale.x - bg.x - bg.z),
				Mathf.Max(0f, mBG.cachedTransform.localScale.y - bg.y - bg.w));

			float val = mInverted ? 1f - mScroll : mScroll;

			if (mDir == Direction.Horizontal)
			{
				Vector2 fgs = new Vector2(bgs.x * mSize, bgs.y);

				mFG.pivot = UIWidget.Pivot.Left;
				mBG.pivot = UIWidget.Pivot.Left;
				mBG.cachedTransform.localPosition = Vector3.zero;
				mFG.cachedTransform.localPosition = new Vector3(bg.x - fg.x + (bgs.x - fgs.x) * val, 0f, 0f);
				//mFG.cachedTransform.localScale = new Vector3(fgs.x + fg.x + fg.z, fgs.y + fg.y + fg.w, 1f);
				// modified by shinriyo
				mFG.cachedTransform.localScale = new Vector3(fgs.x + fg.x + fg.z, mFG.cachedTransform.localScale.y, 1f);
				if (val < 0.999f && val > 0.001f) mFG.MakePixelPerfect();
			}
			else//vertical
			{
				Vector2 fgs = new Vector2(bgs.x, bgs.y * mSize);

				mFG.pivot = UIWidget.Pivot.Top;
				mBG.pivot = UIWidget.Pivot.Top;
				mBG.cachedTransform.localPosition = Vector3.zero;
				mFG.cachedTransform.localPosition = new Vector3(0f, -bg.y + fg.y - (bgs.y - fgs.y) * val, 0f);
//				mFG.cachedTransform.localScale = new Vector3(fgs.x + fg.x + fg.z, fgs.y + fg.y + fg.w, 1f);
				// modified by shinriyo
				mFG.cachedTransform.localScale = new Vector3(mFG.cachedTransform.localScale.x, fgs.y + fg.y + fg.w, 1f);
				if (val < 0.999f && val > 0.001f) mFG.MakePixelPerfect();
			}
		}
	}