From 4ff3ba8dfc01bdcd2f0962fc907cec4320a398a8 Mon Sep 17 00:00:00 2001 From: Firerise9402 <90978630+Firerise9402@users.noreply.github.com> Date: Thu, 17 Aug 2023 14:52:04 -0400 Subject: [PATCH 1/2] fix units --- Assets/Scripts/Minigames.cs | 4 ++-- Assets/Scripts/StaticCamera.cs | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index c03f0e345..8efcf62a5 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -715,8 +715,8 @@ namespace HeavenStudio ), new GameAction("scale letterbox", "Scale Letterbox", 1f, true, new List() { - new Param("valA", new EntityTypes.Float(0, 50, 1), "Scale Letterbox X"), - new Param("valB", new EntityTypes.Float(0, 50, 1), "Scale Letterbox Y"), + new Param("valA", new EntityTypes.Float(0, 200, 100), "Scale Letterbox X"), + new Param("valB", new EntityTypes.Float(0, 200, 100), "Scale Letterbox Y"), new Param("ease", Util.EasingFunction.Ease.Linear, "Ease Type"), new Param("axis", StaticCamera.ViewAxis.All, "Axis", "The axis to scale the letterbox in") } diff --git a/Assets/Scripts/StaticCamera.cs b/Assets/Scripts/StaticCamera.cs index 8c1f5b480..1b7f741e8 100644 --- a/Assets/Scripts/StaticCamera.cs +++ b/Assets/Scripts/StaticCamera.cs @@ -16,6 +16,7 @@ namespace HeavenStudio { [SerializeField] RectTransform canvas; [SerializeField] GameObject overlayView; + [SerializeField] RectTransform parentView; [SerializeField] Image ambientBg; [SerializeField] GameObject ambientBgGO; @@ -247,14 +248,14 @@ namespace HeavenStudio switch (e["axis"]) { case (int) ViewAxis.X: - letterbox.x = func(letterboxLast.x, e["valA"], Mathf.Min(prog, 1f)) * AspectRatioWidth; + letterbox.x = func(letterboxLast.x, e["valA"] * .01f * parentView.localScale.x, Mathf.Min(prog, 1f)) * AspectRatioWidth; break; case (int) ViewAxis.Y: - letterbox.y = func(letterboxLast.y, e["valB"], Mathf.Min(prog, 1f)) * AspectRatioHeight; + letterbox.y = func(letterboxLast.y, e["valB"] * .01f * parentView.localScale.y, Mathf.Min(prog, 1f)) * AspectRatioHeight; break; default: - float dx = func(letterboxLast.x, e["valA"], Mathf.Min(prog, 1f)) * AspectRatioWidth; - float dy = func(letterboxLast.y, e["valB"], Mathf.Min(prog, 1f)) * AspectRatioHeight; + float dx = func(letterboxLast.x, e["valA"] * .01f * parentView.localScale.x, Mathf.Min(prog, 1f)) * AspectRatioWidth; + float dy = func(letterboxLast.y, e["valB"] * .01f * parentView.localScale.y, Mathf.Min(prog, 1f)) * AspectRatioHeight; letterbox = new Vector3(dx, dy, 1); break; } @@ -264,13 +265,13 @@ namespace HeavenStudio switch (e["axis"]) { case (int) ViewAxis.X: - letterboxLast.x = e["valA"] * AspectRatioWidth; + letterboxLast.x = e["valA"] * .01f * parentView.localScale.x * AspectRatioWidth; break; case (int) ViewAxis.Y: - letterboxLast.y = e["valB"] * AspectRatioHeight; + letterboxLast.y = e["valB"] * .01f * parentView.localScale.y * AspectRatioHeight; break; default: - letterboxLast = new Vector3(e["valA"] * AspectRatioWidth, e["valB"] * AspectRatioHeight, 1); + letterboxLast = new Vector3(e["valA"] * .01f * parentView.localScale.x * AspectRatioWidth, e["valB"] * .01f * canvas.localScale.y * AspectRatioHeight, 1); break; } } From 9b5cf2cda63039ea33caad13e744a61523e53446 Mon Sep 17 00:00:00 2001 From: Firerise9402 <90978630+Firerise9402@users.noreply.github.com> Date: Sat, 19 Aug 2023 12:32:21 -0400 Subject: [PATCH 2/2] Final touches I think, ready to pr maybe --- Assets/Scenes/Editor.unity | 9 ++++ Assets/Scripts/Minigames.cs | 21 +++++---- Assets/Scripts/StaticCamera.cs | 82 +++++++++++++++++----------------- 3 files changed, 60 insertions(+), 52 deletions(-) diff --git a/Assets/Scenes/Editor.unity b/Assets/Scenes/Editor.unity index decf3b269..06c9df167 100644 --- a/Assets/Scenes/Editor.unity +++ b/Assets/Scenes/Editor.unity @@ -13806,6 +13806,10 @@ PrefabInstance: propertyPath: canvasObj value: objectReference: {fileID: 1638236449} + - target: {fileID: 4035854539513523048, guid: 720073bc7682b1441bece7116681f72c, type: 3} + propertyPath: parentView + value: + objectReference: {fileID: 1112762038} - target: {fileID: 4035854539513523048, guid: 720073bc7682b1441bece7116681f72c, type: 3} propertyPath: letterboxMask value: @@ -23634,6 +23638,11 @@ RectTransform: m_AnchoredPosition: {x: -408.97968, y: -17} m_SizeDelta: {x: -817.96, y: -46.29} m_Pivot: {x: 0.5, y: 0.5} +--- !u!224 &1112762038 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 2077856143944097172, guid: 720073bc7682b1441bece7116681f72c, type: 3} + m_PrefabInstance: {fileID: 631525709} + m_PrefabAsset: {fileID: 0} --- !u!1 &1121370303 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index 8efcf62a5..795202220 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -715,29 +715,28 @@ namespace HeavenStudio ), new GameAction("scale letterbox", "Scale Letterbox", 1f, true, new List() { - new Param("valA", new EntityTypes.Float(0, 200, 100), "Scale Letterbox X"), - new Param("valB", new EntityTypes.Float(0, 200, 100), "Scale Letterbox Y"), + new Param("valA", new EntityTypes.Integer(0, 200, 100), "Scale Letterbox X"), + new Param("valB", new EntityTypes.Integer(0, 200, 100), "Scale Letterbox Y"), new Param("ease", Util.EasingFunction.Ease.Linear, "Ease Type"), new Param("axis", StaticCamera.ViewAxis.All, "Axis", "The axis to scale the letterbox in") } ), - new GameAction("complex pan", "Pan Viewport(Complex)", 1f, true, new List() + new GameAction("tile screen", "Tile Screen", 1f, true, new List() { - new Param("valA", new EntityTypes.Float(-50, 50, 1), "Pan Viewport X"), - new Param("valB", new EntityTypes.Float(-50, 50, 1), "Pan Viewport Y"), + new Param("valA", new EntityTypes.Float(1, 50, 1), "Tile Screen X"), + new Param("valB", new EntityTypes.Float(1, 50, 1), "Tile Screen Y"), new Param("ease", Util.EasingFunction.Ease.Linear, "Ease Type"), - new Param("axis", StaticCamera.ViewAxis.All, "Axis", "The axis to pan the viewport in") + new Param("axis", StaticCamera.ViewAxis.All, "Axis", "The axis to tile the screen in") } ), - new GameAction("complex scale", "Scale Viewport(Complex)", 1f, true, new List() + new GameAction("pan tiles", "Pan Tiles", 1f, true, new List() { - new Param("valA", new EntityTypes.Float(0, 200, 100), "Scale Viewport X"), - new Param("valB", new EntityTypes.Float(0, 200, 100), "Scale Viewport Y"), + new Param("valA", new EntityTypes.Float(-50, 50, 1), "Pan Tiles X"), + new Param("valB", new EntityTypes.Float(-50, 50, 1), "Pan Tiles Y"), new Param("ease", Util.EasingFunction.Ease.Linear, "Ease Type"), - new Param("axis", StaticCamera.ViewAxis.All, "Axis", "The axis to scale the viewport in") + new Param("axis", StaticCamera.ViewAxis.All, "Axis", "The axis to pan the tiles in") } ), - new GameAction("display textbox", "Display Textbox", 1f, true, new List() { new Param("text1", "", "Text", "The text to display in the textbox (Rich Text is supported!)"), diff --git a/Assets/Scripts/StaticCamera.cs b/Assets/Scripts/StaticCamera.cs index 1b7f741e8..a714aef9b 100644 --- a/Assets/Scripts/StaticCamera.cs +++ b/Assets/Scripts/StaticCamera.cs @@ -41,15 +41,15 @@ namespace HeavenStudio private List scaleEvents = new(); private List rotationEvents = new(); private List letterboxEvents = new(); - private List complexPanEvents = new(); - private List complexScaleEvents = new(); + private List panTileEvents = new(); + private List tileScreenEvents = new(); static Vector3 defaultPan = new Vector3(0, 0, 0); static Vector3 defaultScale = new Vector3(1, 1, 1); static float defaultRotation = 0; static Vector3 defaultLetterbox = new Vector3(1, 1, 1); - static Vector3 defaultComplexPan = new Vector3(0, 0, 0); - static Vector3 defaultComplexScale = new Vector3(1, 1, 1); + static Vector3 defaultTilePan = new Vector3(0, 0, 0); + static Vector3 defaultScreenTile = new Vector3(1, 1, 1); private static Vector3 pan; private static Vector3 scale; @@ -57,15 +57,15 @@ namespace HeavenStudio private static Vector3 letterbox; private static Vector3 panInv; private static Vector3 scaleInv; - private static Vector3 complexPan; - private static Vector3 complexScale; + private static Vector3 tilePan; + private static Vector3 screenTile; private static Vector3 panLast; private static Vector3 scaleLast; private static float rotationLast; private static Vector3 letterboxLast; - private static Vector3 complexPanLast; - private static Vector3 complexScaleLast; + private static Vector3 tilePanLast; + private static Vector3 screenTileLast; private void Awake() { @@ -84,8 +84,8 @@ namespace HeavenStudio letterboxLast = defaultLetterbox; scaleLast = defaultScale; rotationLast = defaultRotation; - complexPanLast = defaultComplexPan; - complexScaleLast = defaultComplexScale; + tilePanLast = defaultTilePan; + screenTileLast = defaultScreenTile; ToggleLetterboxBg(PersistentDataManager.gameSettings.letterboxBgEnable); ToggleLetterboxGlow(PersistentDataManager.gameSettings.letterboxFxEnable); @@ -99,22 +99,22 @@ namespace HeavenStudio scaleEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "scale view" }); rotationEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "rotate view" }); letterboxEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "scale letterbox" }); - complexPanEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "complex pan"}); - complexScaleEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "complex scale" }); + panTileEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "pan tiles"}); + tileScreenEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "tile screen" }); panLast = defaultPan; letterboxLast = defaultLetterbox; scaleLast = defaultScale; rotationLast = defaultRotation; - complexPanLast = defaultComplexPan; - complexScaleLast = defaultComplexScale; + tilePanLast = defaultTilePan; + screenTileLast = defaultScreenTile; UpdatePan(); UpdateRotation(); UpdateScale(); UpdateLetterbox(); - UpdateComplexPan(); - UpdatecomplexScale(); + UpdateTilePan(); + UpdateScreenTile(); } // Update is called once per frame @@ -124,8 +124,8 @@ namespace HeavenStudio UpdatePan(); UpdateRotation(); UpdateScale(); - UpdateComplexPan(); - UpdatecomplexScale(); + UpdateTilePan(); + UpdateScreenTile(); canvas.localPosition = pan; canvas.eulerAngles = new Vector3(0, 0, rotation); @@ -135,7 +135,7 @@ namespace HeavenStudio scaleInv.y /= letterbox.y; scaleInv.z /= letterbox.z; canvas.localScale = scaleInv; - viewportTexture.uvRect = new Rect(complexPan.x, complexPan.y, complexScale.x, complexScale.y); + viewportTexture.uvRect = new Rect(tilePan.x, tilePan.y, screenTile.x, screenTile.y); } private void UpdatePan() @@ -278,9 +278,9 @@ namespace HeavenStudio } } - private void UpdateComplexPan() + private void UpdateTilePan() { - foreach (var e in complexPanEvents) + foreach (var e in panTileEvents) { float prog = Conductor.instance.GetPositionFromBeat(e.beat, e.length); if (prog >= 0f) @@ -289,15 +289,15 @@ namespace HeavenStudio switch (e["axis"]) { case (int) ViewAxis.X: - complexPan.x = func(complexPanLast.x, e["valA"], Mathf.Min(prog, 1f)); + tilePan.x = func(tilePanLast.x, e["valA"], Mathf.Min(prog, 1f)); break; case (int) ViewAxis.Y: - complexPan.y = func(complexPan.y, e["valB"], Mathf.Min(prog, 1f)); + tilePan.y = func(tilePan.y, e["valB"], Mathf.Min(prog, 1f)); break; default: - float dx = func(complexPanLast.x, e["valA"], Mathf.Min(prog, 1f)); - float dy = func(complexPanLast.y, e["valB"], Mathf.Min(prog, 1f)); - complexPan = new Vector3(dx, dy, 0); + float dx = func(tilePanLast.x, e["valA"], Mathf.Min(prog, 1f)); + float dy = func(tilePanLast.y, e["valB"], Mathf.Min(prog, 1f)); + tilePan = new Vector3(dx, dy, 0); break; } } @@ -306,22 +306,22 @@ namespace HeavenStudio switch (e["axis"]) { case (int) ViewAxis.X: - complexPanLast.x = e["valA"]; + tilePanLast.x = e["valA"]; break; case (int) ViewAxis.Y: - complexPanLast.y = e["valB"]; + tilePanLast.y = e["valB"]; break; default: - complexPanLast = new Vector3(e["valA"], e["valB"], 0); + tilePanLast = new Vector3(e["valA"], e["valB"], 0); break; } } } } - private void UpdatecomplexScale() + private void UpdateScreenTile() { - foreach (var e in complexScaleEvents) + foreach (var e in tileScreenEvents) { float prog = Conductor.instance.GetPositionFromBeat(e.beat, e.length); if (prog >= 0f) @@ -330,15 +330,15 @@ namespace HeavenStudio switch (e["axis"]) { case (int) ViewAxis.X: - complexScale.x = func(complexScaleLast.x, e["valA"] * .01f, Mathf.Min(prog, 1f)) * AspectRatioWidth; + screenTile.x = func(screenTileLast.x, e["valA"] * canvas.localScale.x, Mathf.Min(prog, 1f)) * AspectRatioWidth; break; case (int) ViewAxis.Y: - complexScale.y = func(complexScaleLast.y, e["valB"] * .01f, Mathf.Min(prog, 1f)) * AspectRatioHeight; + screenTile.y = func(screenTileLast.y, e["valB"] * canvas.localScale.y, Mathf.Min(prog, 1f)) * AspectRatioHeight; break; default: - float dx = func(complexScaleLast.x, e["valA"] * .01f, Mathf.Min(prog, 1f)) * AspectRatioWidth; - float dy = func(complexScaleLast.y, e["valB"] * .01f, Mathf.Min(prog, 1f)) * AspectRatioHeight; - complexScale = new Vector3(dx, dy, 1); + float dx = func(screenTileLast.x, e["valA"] * canvas.localScale.x, Mathf.Min(prog, 1f)) * AspectRatioWidth; + float dy = func(screenTileLast.y, e["valB"] * canvas.localScale.y, Mathf.Min(prog, 1f)) * AspectRatioHeight; + screenTile = new Vector3(dx, dy, 1); break; } } @@ -347,13 +347,13 @@ namespace HeavenStudio switch (e["axis"]) { case (int) ViewAxis.X: - complexScaleLast.x = e["valA"] * .01f * AspectRatioWidth; + screenTileLast.x = e["valA"] * canvas.localScale.x * AspectRatioWidth; break; case (int) ViewAxis.Y: - complexScaleLast.y = e["valB"] * .01f * AspectRatioHeight; + screenTileLast.y = e["valB"] * canvas.localScale.y * AspectRatioHeight; break; default: - complexScaleLast = new Vector3(e["valA"] * .01f * AspectRatioWidth, e["valB"] * .01f * AspectRatioHeight, 1); + screenTileLast = new Vector3(e["valA"] * canvas.localScale.x * AspectRatioWidth, e["valB"] * canvas.localScale.y * AspectRatioHeight, 1); break; } } @@ -366,8 +366,8 @@ namespace HeavenStudio scale = defaultScale; rotation = defaultRotation; letterbox = defaultLetterbox; - complexPan = defaultComplexPan; - complexScale = defaultComplexScale; + tilePan = defaultTilePan; + screenTile = defaultScreenTile; } public void ToggleOverlayView(bool toggle)