diff --git a/Assets/Resources/Prefabs/GameView/CamerasEditor.prefab b/Assets/Resources/Prefabs/GameView/CamerasEditor.prefab index aa4d88b9b..6bcb60d8e 100644 --- a/Assets/Resources/Prefabs/GameView/CamerasEditor.prefab +++ b/Assets/Resources/Prefabs/GameView/CamerasEditor.prefab @@ -295,6 +295,7 @@ GameObject: - component: {fileID: 1535126665250126034} - component: {fileID: 1198356187242493155} - component: {fileID: 647613278910435637} + - component: {fileID: 2582851074058764053} m_Layer: 31 m_Name: GameView m_TagString: Untagged @@ -357,6 +358,18 @@ MonoBehaviour: y: 0 width: 1 height: 1 +--- !u!114 &2582851074058764053 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2464883521749415129} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d556607141c07af40b1b5ee71c28c5a6, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &2478945398383251488 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index 689152475..985d5f635 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -1024,6 +1024,27 @@ namespace HeavenStudio new((x, y) => (Util.EasingFunction.Ease)x != Util.EasingFunction.Ease.Instant, new string[] { "tempStart", "tintStart", "colorStart", "hueShiftStart", "satStart", "brightStart", "conStart" }) }), } + }, + new GameAction("screenTiling", "Screen Tiling") + { + resizable = true, + parameters = new() + { + new("xStart", new EntityTypes.Float(1, 100, 1), "Start Horizontal Tiles"), + new("yStart", new EntityTypes.Float(1, 100, 1), "Start Vertical Tiles"), + new("xEnd", new EntityTypes.Float(1, 100, 1), "End Horizontal Tiles"), + new("yEnd", new EntityTypes.Float(1, 100, 1), "End Vertical Tiles"), + + new("xScrollStart", new EntityTypes.Float(-100, 100, 0), "Start Horizontal Scroll"), + new("yScrollStart", new EntityTypes.Float(-100, 100, 0), "Start Vertical Scroll"), + new("xScrollEnd", new EntityTypes.Float(-100, 100, 0), "End Horizontal Scroll"), + new("yScrollEnd", new EntityTypes.Float(-100, 100, 0), "End Vertical Scroll"), + + new("ease", Util.EasingFunction.Ease.Linear, "Ease", "", new() + { + new((x, y) => (Util.EasingFunction.Ease)x != Util.EasingFunction.Ease.Instant, new string[] { "xStart", "yStart", "xScrollStart", "yScrollStart" }) + }), + } } }), }; diff --git a/Assets/Scripts/ScreenTiling.cs b/Assets/Scripts/ScreenTiling.cs new file mode 100644 index 000000000..168636765 --- /dev/null +++ b/Assets/Scripts/ScreenTiling.cs @@ -0,0 +1,62 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using Jukebox; +using UnityEngine.UI; + +namespace HeavenStudio +{ + public class ScreenTiling : MonoBehaviour + { + private RawImage _image; + private RectTransform _rectTransform; + + private List _events = new(); + + private void Awake() + { + _image = GetComponent(); + _rectTransform = GetComponent(); + } + + private void Start() + { + GameManager.instance.onBeatChanged += OnBeatChanged; + } + + public void OnBeatChanged(double beat) + { + _events = EventCaller.GetAllInGameManagerList("vfx", new string[] { "screenTiling" }); + ResetUVRect(); + Update(); + } + + private void Update() + { + foreach (var e in _events) + { + float normalized = Conductor.instance.GetPositionFromBeat(e.beat, e.length); + if (normalized < 0) break; + + float clampNormal = Mathf.Clamp01(normalized); + + var func = Util.EasingFunction.GetEasingFunction((Util.EasingFunction.Ease)e["ease"]); + + float newXTiles = func(e["xStart"], e["xEnd"], clampNormal); + float newYTiles = func(e["yStart"], e["yEnd"], clampNormal); + float newXScroll = func(e["xScrollStart"], e["xScrollEnd"], clampNormal); + float newYScroll = func(e["yScrollStart"], e["yScrollEnd"], clampNormal); + + _image.uvRect = new Rect(newXScroll, newYScroll, newXTiles, newYTiles); + _rectTransform.localScale = new Vector3(1 / newXTiles, 1 / newYTiles); + } + } + + public void ResetUVRect() + { + _image.uvRect = new Rect(0, 0, 1, 1); + _rectTransform.localScale = Vector3.one; + } + } +} + diff --git a/Assets/Scripts/ScreenTiling.cs.meta b/Assets/Scripts/ScreenTiling.cs.meta new file mode 100644 index 000000000..513f13506 --- /dev/null +++ b/Assets/Scripts/ScreenTiling.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d556607141c07af40b1b5ee71c28c5a6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: