screen fit added

This commit is contained in:
Rapandrasmus 2023-11-24 20:45:14 +01:00
parent 247465681f
commit 56f2009e8d
3 changed files with 40 additions and 0 deletions

View file

@ -93,6 +93,9 @@ MonoBehaviour:
ambientBg: {fileID: 5129120947114944961} ambientBg: {fileID: 5129120947114944961}
ambientBgGO: {fileID: 269805006432045765} ambientBgGO: {fileID: 269805006432045765}
letterboxBgGO: {fileID: 3741076794236313655} letterboxBgGO: {fileID: 3741076794236313655}
overlayCanvas: {fileID: 8512930684284350359}
letterboxMask: {fileID: 8925473620302868482}
parentView: {fileID: 2077856143944097172}
camera: {fileID: 378821074852065722} camera: {fileID: 378821074852065722}
--- !u!1 &269805006432045765 --- !u!1 &269805006432045765
GameObject: GameObject:

View file

@ -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") new GameAction("screenTiling", "Tile Screen")
{ {
resizable = true, resizable = true,

View file

@ -21,6 +21,10 @@ namespace HeavenStudio
[SerializeField] GameObject ambientBgGO; [SerializeField] GameObject ambientBgGO;
[SerializeField] GameObject letterboxBgGO; [SerializeField] GameObject letterboxBgGO;
[SerializeField] RectTransform overlayCanvas;
[SerializeField] RectTransform letterboxMask;
[SerializeField] RectTransform parentView;
public static StaticCamera instance { get; private set; } public static StaticCamera instance { get; private set; }
public new Camera camera; public new Camera camera;
@ -37,6 +41,7 @@ namespace HeavenStudio
private List<RiqEntity> panEvents = new(); private List<RiqEntity> panEvents = new();
private List<RiqEntity> scaleEvents = new(); private List<RiqEntity> scaleEvents = new();
private List<RiqEntity> rotationEvents = new(); private List<RiqEntity> rotationEvents = new();
private List<RiqEntity> fitScreenEvents = new();
static Vector3 defaultPan = new Vector3(0, 0, 0); static Vector3 defaultPan = new Vector3(0, 0, 0);
static Vector3 defaultScale = new Vector3(1, 1, 1); static Vector3 defaultScale = new Vector3(1, 1, 1);
@ -78,6 +83,7 @@ namespace HeavenStudio
panEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "pan view" }); panEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "pan view" });
scaleEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "scale view" }); scaleEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "scale view" });
rotationEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "rotate view" }); rotationEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "rotate view" });
fitScreenEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "fitScreen" });
panLast = defaultPan; panLast = defaultPan;
scaleLast = defaultScale; scaleLast = defaultScale;
@ -86,6 +92,7 @@ namespace HeavenStudio
UpdatePan(); UpdatePan();
UpdateRotation(); UpdateRotation();
UpdateScale(); UpdateScale();
UpdateGameScreenFit();
canvas.localPosition = pan; canvas.localPosition = pan;
canvas.eulerAngles = new Vector3(0, 0, rotation); canvas.eulerAngles = new Vector3(0, 0, rotation);
@ -98,12 +105,34 @@ namespace HeavenStudio
UpdatePan(); UpdatePan();
UpdateRotation(); UpdateRotation();
UpdateScale(); UpdateScale();
UpdateGameScreenFit();
canvas.localPosition = pan; canvas.localPosition = pan;
canvas.eulerAngles = new Vector3(0, 0, rotation); canvas.eulerAngles = new Vector3(0, 0, rotation);
canvas.localScale = scale; 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() private void UpdatePan()
{ {
foreach (var e in panEvents) foreach (var e in panEvents)