| 123456789101112131415 |
- using UnityEngine;
- namespace Olympus {
- [ExecuteAlways]
- public sealed class ReferenceViewport : MonoBehaviour
- {
- void LateUpdate()
- {
- var rect=(RectTransform)transform;var parent=rect.parent as RectTransform;if(!parent)return;
- float keyboard=Application.isPlaying&&TouchScreenKeyboard.visible?TouchScreenKeyboard.area.height/Mathf.Max(1,Screen.height)*parent.rect.height:0;
- float height=Mathf.Max(400,parent.rect.height-keyboard);
- float scale=Mathf.Min(parent.rect.width/750,height/1334);
- rect.localScale=Vector3.one*scale;rect.anchoredPosition=new Vector2(0,keyboard*.5f);
- }
- }
- }
|