123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- using System;
- using UnityEngine;
- public class UI_ScreenCover : UI_ScreenFitBase
- {
- protected override void Start()
- {
- this.m_MaskPanel = base.GetComponent<UIPanel>();
- this.m_CoverUI = base.GetComponent<UIWidget>();
- base.Start();
- }
- protected override void Update()
- {
- base.Update();
- }
- protected override void FitAction()
- {
- Vector3 point = new Vector3((float)Screen.width, (float)Screen.height);
- Vector3 vector = UI_ScreenFitBase.PointToScreenPos(point);
- if (!this.m_IsMasking && this.m_CoverUI)
- {
- UI_ScreenCover.CoverType myType = this.m_MyType;
- if (myType != UI_ScreenCover.CoverType.Horizontal)
- {
- if (myType != UI_ScreenCover.CoverType.Vertical)
- {
- if (this.m_UseSceenAsspect)
- {
- this.m_CoverUI.width = (int)(vector.x * 2f * this.m_ScreenRateX);
- this.m_CoverUI.height = (int)(vector.y * 2f * this.m_ScreenRateY);
- }
- else
- {
- this.m_CoverUI.width = (int)vector.x * 2;
- this.m_CoverUI.height = (int)vector.y * 2;
- }
- }
- else
- {
- this.m_CoverUI.height = (int)vector.y * 2;
- if (this.m_AsspectRatio.x != 0f && this.m_AsspectRatio.y != 0f)
- {
- this.m_CoverUI.width = (int)((float)this.m_CoverUI.height * (this.m_AsspectRatio.x / this.m_AsspectRatio.y));
- }
- }
- }
- else
- {
- this.m_CoverUI.width = (int)vector.x * 2;
- if (this.m_AsspectRatio.x != 0f && this.m_AsspectRatio.y != 0f)
- {
- this.m_CoverUI.height = (int)((float)this.m_CoverUI.width * (this.m_AsspectRatio.y / this.m_AsspectRatio.x));
- }
- }
- if (this.m_WidthMax > 0)
- {
- this.m_CoverUI.width = Mathf.Min(this.m_CoverUI.width, this.m_WidthMax);
- }
- if (this.m_HeightMax > 0)
- {
- this.m_CoverUI.height = Mathf.Min(this.m_CoverUI.height, this.m_HeightMax);
- }
- }
- else if (this.m_IsMasking && this.m_MaskPanel)
- {
- Vector4 zero = Vector4.zero;
- UI_ScreenCover.CoverType myType2 = this.m_MyType;
- if (myType2 != UI_ScreenCover.CoverType.Horizontal)
- {
- if (myType2 != UI_ScreenCover.CoverType.Vertical)
- {
- if (this.m_UseSceenAsspect)
- {
- zero.z = (float)((int)(vector.x * 2f * this.m_ScreenRateX));
- zero.w = (float)((int)(vector.y * 2f * this.m_ScreenRateY));
- }
- else
- {
- zero.z = (float)((int)vector.x * 2);
- zero.w = (float)((int)vector.y * 2);
- }
- }
- else
- {
- zero.w = (float)((int)vector.y * 2);
- if (this.m_AsspectRatio.x != 0f && this.m_AsspectRatio.y != 0f)
- {
- zero.z = (float)((int)((float)this.m_MaskPanel.clipTexture.height * (this.m_AsspectRatio.x / this.m_AsspectRatio.y)));
- }
- }
- }
- else
- {
- zero.z = (float)((int)vector.x * 2);
- if (this.m_AsspectRatio.x != 0f && this.m_AsspectRatio.y != 0f)
- {
- zero.w = (float)((int)((float)this.m_MaskPanel.clipTexture.width * (this.m_AsspectRatio.y / this.m_AsspectRatio.x)));
- }
- }
- if (this.m_WidthMax > 0)
- {
- zero.z = Mathf.Min(zero.z, (float)this.m_WidthMax);
- }
- if (this.m_HeightMax > 0)
- {
- zero.w = Mathf.Min(zero.w, (float)this.m_HeightMax);
- }
- this.m_MaskPanel.baseClipRegion = zero;
- }
- }
- private UIPanel m_MaskPanel;
- private UIWidget m_CoverUI;
- [SerializeField]
- private UI_ScreenCover.CoverType m_MyType;
- [SerializeField]
- [Header("解像度に合わせたマスキングを行うか")]
- private bool m_IsMasking;
- [SerializeField]
- [Header("Horizontal・Vertical時の画像の比率((0, 0)で比率固定されない)")]
- private Vector2 m_AsspectRatio = Vector2.zero;
- [SerializeField]
- [Header("解像度に対する割合で比率を固定する")]
- private bool m_UseSceenAsspect;
- [SerializeField]
- [Range(0f, 1f)]
- private float m_ScreenRateX = 1f;
- [SerializeField]
- [Range(0f, 1f)]
- private float m_ScreenRateY = 1f;
- [SerializeField]
- [Header("最大サイズ(-1で無効)")]
- private int m_WidthMax = -1;
- [SerializeField]
- private int m_HeightMax = -1;
- private enum CoverType
- {
- All,
- Horizontal,
- Vertical
- }
- }
|