From 3c2a867f3f63e429625b42dc4e3650b14a804fd9 Mon Sep 17 00:00:00 2001 From: Firerise9402 <90978630+Firerise9402@users.noreply.github.com> Date: Sat, 12 Aug 2023 13:43:03 -0400 Subject: [PATCH] i did another funny --- Assets/Scenes/Editor.unity | 54 +++--------- Assets/Scripts/Minigames.cs | 19 +++- Assets/Scripts/StaticCamera.cs | 153 ++++++++++++++++++++++++--------- 3 files changed, 141 insertions(+), 85 deletions(-) diff --git a/Assets/Scenes/Editor.unity b/Assets/Scenes/Editor.unity index e460d2904..10937c2bb 100644 --- a/Assets/Scenes/Editor.unity +++ b/Assets/Scenes/Editor.unity @@ -6402,7 +6402,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 0, y: 0.5} - m_AnchoredPosition: {x: 194, y: 0} + m_AnchoredPosition: {x: 194.00002, y: 0} m_SizeDelta: {x: 40, y: 40} m_Pivot: {x: 0, y: 0.5} --- !u!114 &285739500 @@ -13774,6 +13774,14 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 1535126665250126034, guid: 720073bc7682b1441bece7116681f72c, type: 3} + propertyPath: m_SizeDelta.x + value: 1728 + objectReference: {fileID: 0} + - target: {fileID: 1535126665250126034, guid: 720073bc7682b1441bece7116681f72c, type: 3} + propertyPath: m_SizeDelta.y + value: 972 + objectReference: {fileID: 0} - target: {fileID: 1535126665250126034, guid: 720073bc7682b1441bece7116681f72c, type: 3} propertyPath: m_ConstrainProportionsScale value: 0 @@ -15753,7 +15761,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 0, y: 0.5} - m_AnchoredPosition: {x: 100, y: 0} + m_AnchoredPosition: {x: 100.000015, y: 0} m_SizeDelta: {x: 40, y: 40} m_Pivot: {x: 0, y: 0.5} --- !u!114 &689781278 @@ -24782,7 +24790,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 1, y: 0.5} - m_AnchoredPosition: {x: 0, y: 129.94975} + m_AnchoredPosition: {x: 0, y: 105.87459} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1154875944 @@ -33259,7 +33267,7 @@ MonoBehaviour: m_TargetGraphic: {fileID: 1292844878} m_HandleRect: {fileID: 1292844877} m_Direction: 2 - m_Value: 1 + m_Value: 0 m_Size: 1 m_NumberOfSteps: 0 m_OnValueChanged: @@ -33685,40 +33693,6 @@ GameObject: m_CorrespondingSourceObject: {fileID: 2464883521749415129, guid: 720073bc7682b1441bece7116681f72c, type: 3} m_PrefabInstance: {fileID: 631525709} m_PrefabAsset: {fileID: 0} ---- !u!1818360610 &1638236453 -ScaleConstraint: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1638236449} - m_Enabled: 1 - m_Weight: 1 - m_ScaleAtRest: {x: 1, y: 1, z: 1} - m_ScaleOffset: {x: 1, y: 1, z: 1} - m_AffectScalingX: 1 - m_AffectScalingY: 1 - m_AffectScalingZ: 1 - m_IsContraintActive: 1 - m_IsLocked: 1 - m_Sources: [] ---- !u!1818360608 &1638236454 -PositionConstraint: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1638236449} - m_Enabled: 1 - m_Weight: 1 - m_TranslationAtRest: {x: 0, y: 0, z: 0} - m_TranslationOffset: {x: 0, y: 0, z: 0} - m_AffectTranslationX: 1 - m_AffectTranslationY: 1 - m_AffectTranslationZ: 1 - m_IsContraintActive: 0 - m_IsLocked: 0 - m_Sources: [] --- !u!1 &1647324172 GameObject: m_ObjectHideFlags: 0 @@ -36943,7 +36917,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 0, y: -84.98999} + m_AnchoredPosition: {x: 0, y: -84.98996} m_SizeDelta: {x: 320, y: -84.99} m_Pivot: {x: 0, y: 1} --- !u!1 &1852819572 @@ -41664,7 +41638,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 0, y: 0.5} - m_AnchoredPosition: {x: 147, y: 0} + m_AnchoredPosition: {x: 147.00002, y: 0} m_SizeDelta: {x: 40, y: 40} m_Pivot: {x: 0, y: 0.5} --- !u!114 &2125404437 diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index d662b30db..ec9091277 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -718,8 +718,23 @@ namespace HeavenStudio 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("ease", Util.EasingFunction.Ease.Linear, "Ease Type"), - new Param("axis", StaticCamera.ViewAxis.All, "Axis", "The axis to scale the letterbox in"), - new Param("toggle", true, "Mirror scaling", "Mirror the scaling of the letterbox via scaling the minigame as well.") + new Param("axis", StaticCamera.ViewAxis.All, "Axis", "The axis to scale the letterbox in") + } + ), + new GameAction("complex pan", "Scale Viewport(Complex)", 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("ease", Util.EasingFunction.Ease.Linear, "Ease Type"), + new Param("axis", StaticCamera.ViewAxis.All, "Axis", "The axis to pan the viewport in") + } + ), + new GameAction("complex scale", "Scale Viewport(Complex)", 1f, true, new List() + { + new Param("valA", new EntityTypes.Float(0, 50, 1), "Scale Viewport X"), + new Param("valB", new EntityTypes.Float(0, 50, 1), "Scale Viewport Y"), + new Param("ease", Util.EasingFunction.Ease.Linear, "Ease Type"), + new Param("axis", StaticCamera.ViewAxis.All, "Axis", "The axis to scale the viewport in") } ), diff --git a/Assets/Scripts/StaticCamera.cs b/Assets/Scripts/StaticCamera.cs index 04407add8..86d25be85 100644 --- a/Assets/Scripts/StaticCamera.cs +++ b/Assets/Scripts/StaticCamera.cs @@ -21,7 +21,7 @@ namespace HeavenStudio [SerializeField] GameObject ambientBgGO; [SerializeField] GameObject letterboxBgGO; [SerializeField] RectTransform letterboxMask; - [SerializeField] GameObject maskObj; + [SerializeField] RawImage viewportTexture; public static StaticCamera instance { get; private set; } public new Camera camera; @@ -40,11 +40,15 @@ namespace HeavenStudio private List scaleEvents = new(); private List rotationEvents = new(); private List letterboxEvents = new(); + private List complexPanEvents = new(); + private List complexScaleEvents = 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); private static Vector3 pan; private static Vector3 scale; @@ -52,14 +56,15 @@ namespace HeavenStudio private static Vector3 letterbox; private static Vector3 panInv; private static Vector3 scaleInv; - - private static bool toggle; - private Transform[] children = null; + private static Vector3 complexPan; + private static Vector3 complexScale; 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 void Awake() { @@ -78,13 +83,11 @@ namespace HeavenStudio letterboxLast = defaultLetterbox; scaleLast = defaultScale; rotationLast = defaultRotation; + complexPanLast = defaultComplexPan; + complexScaleLast = defaultComplexScale; ToggleLetterboxBg(PersistentDataManager.gameSettings.letterboxBgEnable); ToggleLetterboxGlow(PersistentDataManager.gameSettings.letterboxFxEnable); - /* - children = new Transform[ maskObj.transform.childCount ]; - foreach(Transform T in transform) - children.add(T);*/ } public void OnBeatChanged(double beat) @@ -95,16 +98,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" }); panLast = defaultPan; letterboxLast = defaultLetterbox; scaleLast = defaultScale; rotationLast = defaultRotation; + complexPanLast = defaultComplexPan; + complexScaleLast = defaultComplexScale; UpdatePan(); UpdateRotation(); UpdateScale(); UpdateLetterbox(); + UpdateComplexPan(); + UpdatecomplexScale(); } // Update is called once per frame @@ -114,34 +123,18 @@ namespace HeavenStudio UpdatePan(); UpdateRotation(); UpdateScale(); + UpdateComplexPan(); + UpdatecomplexScale(); canvas.localPosition = pan; - canvas.localScale = scale; canvas.eulerAngles = new Vector3(0, 0, rotation); - //if(!toggle)canvas.localPosition = panInv; - //if(!toggle)canvas.localScale = scaleInv; - if(!toggle) - { - //canvas.transform.SetParent(null); dont do that - letterboxMask.localScale = letterbox; - canvas.transform.localScale = scale; - //letterboxMask.localScale = letterbox; - - } //heyo future me FIX THIS MESS PLEASEAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - - //canvas.localScale = canvas.InverseTransformDirection(scaleInv); - /*if(!toggle) - { - canvas.localPosition = canvas.InverseTransformVector(panInv); - - canvas.eulerAngles = canvas.TransformVector(new Vector3(0, 0, rotation)); - toggle = true; - }else{ - canvas.localPosition = pan; - canvas.localScale = scale; - canvas.eulerAngles = new Vector3(0, 0, rotation); - } - */ + letterboxMask.localScale = letterbox; + scaleInv = scale; + scaleInv.x /= letterbox.x; + scaleInv.y /= letterbox.y; + scaleInv.z /= letterbox.z; + canvas.localScale = scaleInv; + viewportTexture.uvRect = new Rect(complexPan.x, complexPan.y, complexScale.x, complexScale.y); } private void UpdatePan() @@ -255,23 +248,14 @@ namespace HeavenStudio { case (int) ViewAxis.X: letterbox.x = func(letterboxLast.x, e["valA"], Mathf.Min(prog, 1f)) * AspectRatioWidth; - panInv = pan; - scaleInv = scale; - toggle = e["toggle"]; break; case (int) ViewAxis.Y: letterbox.y = func(letterboxLast.y, e["valB"], Mathf.Min(prog, 1f)) * AspectRatioHeight; - panInv = pan; - scaleInv = scale; - toggle = e["toggle"]; 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; letterbox = new Vector3(dx, dy, 1); - panInv = pan; - scaleInv = scale; - toggle = e["toggle"]; break; } } @@ -293,13 +277,96 @@ namespace HeavenStudio } } + private void UpdateComplexPan() + { + foreach (var e in complexPanEvents) + { + float prog = Conductor.instance.GetPositionFromBeat(e.beat, e.length); + if (prog >= 0f) + { + Util.EasingFunction.Function func = Util.EasingFunction.GetEasingFunction((Util.EasingFunction.Ease) e["ease"]); + switch (e["axis"]) + { + case (int) ViewAxis.X: + complexPan.x = func(complexPanLast.x, e["valA"], Mathf.Min(prog, 1f)); + break; + case (int) ViewAxis.Y: + complexPan.y = func(complexPan.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); + break; + } + } + if (prog > 1f) + { + switch (e["axis"]) + { + case (int) ViewAxis.X: + complexPanLast.x = e["valA"]; + break; + case (int) ViewAxis.Y: + complexPanLast.y = e["valB"]; + break; + default: + complexPanLast = new Vector3(e["valA"], e["valB"], 0); + break; + } + } + } + } + + private void UpdatecomplexScale() + { + foreach (var e in complexScaleEvents) + { + float prog = Conductor.instance.GetPositionFromBeat(e.beat, e.length); + if (prog >= 0f) + { + Util.EasingFunction.Function func = Util.EasingFunction.GetEasingFunction((Util.EasingFunction.Ease) e["ease"]); + switch (e["axis"]) + { + case (int) ViewAxis.X: + complexScale.x = func(complexScaleLast.x, e["valA"], Mathf.Min(prog, 1f)) * AspectRatioWidth; + break; + case (int) ViewAxis.Y: + complexScale.y = func(complexScaleLast.y, e["valB"], Mathf.Min(prog, 1f)) * AspectRatioHeight; + break; + default: + float dx = func(complexScaleLast.x, e["valA"], Mathf.Min(prog, 1f)) * AspectRatioWidth; + float dy = func(complexScaleLast.y, e["valB"], Mathf.Min(prog, 1f)) * AspectRatioHeight; + complexScale = new Vector3(dx, dy, 1); + break; + } + } + if (prog > 1f) + { + switch (e["axis"]) + { + case (int) ViewAxis.X: + complexScaleLast.x = e["valA"] * AspectRatioWidth; + break; + case (int) ViewAxis.Y: + complexScaleLast.y = e["valB"] * AspectRatioHeight; + break; + default: + complexScaleLast = new Vector3(e["valA"] * AspectRatioWidth, e["valB"] * AspectRatioHeight, 1); + break; + } + } + } + } + public static void Reset() { pan = defaultPan; scale = defaultScale; rotation = defaultRotation; letterbox = defaultLetterbox; - toggle = true; + complexPan = defaultComplexPan; + complexScale = defaultComplexScale; } public void ToggleOverlayView(bool toggle)