본문 바로가기
개발/C#

유니티 C# NGUI 가변 해상도 대응 IOS 간단 사용법

by SPNK 2022. 8. 28.
반응형
  • UIroot.cs 코드 변경
	public void UpdateScale(bool updateAnchors = true)
	{
		if (mTrans != null)
		{
			float calcActiveHeight = activeHeight;

			if (calcActiveHeight > 0f)
			{
				float size = 2f / calcActiveHeight;

				Vector3 ls = mTrans.localScale;

				if (!(Mathf.Abs(ls.x - size) <= float.Epsilon) ||
					!(Mathf.Abs(ls.y - size) <= float.Epsilon) ||
					!(Mathf.Abs(ls.z - size) <= float.Epsilon))
				{
					//mTrans.localScale = new Vector3(size, size, size);
					float x_value = (NGUITools.screenSize.x / Screen.width);
					float temp_value = (Screen.height * x_value);
					float y_value = NGUITools.screenSize.y / temp_value;

					mTrans.localScale = new Vector3(size, size * y_value, size);
					if (updateAnchors) BroadcastMessage("UpdateAnchors", SendMessageOptions.DontRequireReceiver);
				}
			}
		}
	}
반응형

댓글