diff --git a/Assets/Resources/Prefabs/GameView/CamerasEditor.prefab b/Assets/Resources/Prefabs/GameView/CamerasEditor.prefab index 6bcb60d8e..17e960aa1 100644 --- a/Assets/Resources/Prefabs/GameView/CamerasEditor.prefab +++ b/Assets/Resources/Prefabs/GameView/CamerasEditor.prefab @@ -93,6 +93,9 @@ MonoBehaviour: ambientBg: {fileID: 5129120947114944961} ambientBgGO: {fileID: 269805006432045765} letterboxBgGO: {fileID: 3741076794236313655} + overlayCanvas: {fileID: 8512930684284350359} + letterboxMask: {fileID: 8925473620302868482} + parentView: {fileID: 2077856143944097172} camera: {fileID: 378821074852065722} --- !u!1 &269805006432045765 GameObject: diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index efdf93bd4..7fb7006cb 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -1025,6 +1025,14 @@ namespace HeavenStudio }), } }, + new GameAction("fitScreen", "Fit Game To Screen") + { + defaultLength = 0.5f, + parameters = new() + { + new("enable", true, "Enabled") + } + }, new GameAction("screenTiling", "Tile Screen") { resizable = true, diff --git a/Assets/Scripts/StaticCamera.cs b/Assets/Scripts/StaticCamera.cs index c92a1bc99..09708bc40 100644 --- a/Assets/Scripts/StaticCamera.cs +++ b/Assets/Scripts/StaticCamera.cs @@ -21,6 +21,10 @@ namespace HeavenStudio [SerializeField] GameObject ambientBgGO; [SerializeField] GameObject letterboxBgGO; + [SerializeField] RectTransform overlayCanvas; + [SerializeField] RectTransform letterboxMask; + [SerializeField] RectTransform parentView; + public static StaticCamera instance { get; private set; } public new Camera camera; @@ -37,6 +41,7 @@ namespace HeavenStudio private List panEvents = new(); private List scaleEvents = new(); private List rotationEvents = new(); + private List fitScreenEvents = new(); static Vector3 defaultPan = new Vector3(0, 0, 0); static Vector3 defaultScale = new Vector3(1, 1, 1); @@ -78,6 +83,7 @@ namespace HeavenStudio panEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "pan view" }); scaleEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "scale view" }); rotationEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "rotate view" }); + fitScreenEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "fitScreen" }); panLast = defaultPan; scaleLast = defaultScale; @@ -86,6 +92,7 @@ namespace HeavenStudio UpdatePan(); UpdateRotation(); UpdateScale(); + UpdateGameScreenFit(); canvas.localPosition = pan; canvas.eulerAngles = new Vector3(0, 0, rotation); @@ -98,12 +105,34 @@ namespace HeavenStudio UpdatePan(); UpdateRotation(); UpdateScale(); + UpdateGameScreenFit(); canvas.localPosition = pan; canvas.eulerAngles = new Vector3(0, 0, rotation); canvas.localScale = scale; } + private void UpdateGameScreenFit() + { + var curBeat = Conductor.instance.songPositionInBeatsAsDouble; + letterboxMask.localScale = new Vector3(1, 1, 1); + overlayCanvas.localScale = new Vector3(1, 1, 1); + foreach (var e in fitScreenEvents) + { + if (curBeat < e.beat) break; + if (e["enable"]) + { + letterboxMask.localScale = new Vector3(parentView.sizeDelta.x / 16, parentView.sizeDelta.y / 9, 1); + overlayCanvas.localScale = new Vector3(parentView.sizeDelta.x / 16, parentView.sizeDelta.y / 9, 1); + } + else + { + letterboxMask.localScale = new Vector3(1, 1, 1); + overlayCanvas.localScale = new Vector3(1, 1, 1); + } + } + } + private void UpdatePan() { foreach (var e in panEvents)