screen tiling added

This commit is contained in:
Rapandrasmus 2023-11-23 22:18:25 +01:00
parent e3d25a53e9
commit e38d912810
4 changed files with 107 additions and 0 deletions

View file

@ -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

View file

@ -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" })
}),
}
}
}),
};

View file

@ -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<RiqEntity> _events = new();
private void Awake()
{
_image = GetComponent<RawImage>();
_rectTransform = GetComponent<RectTransform>();
}
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;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d556607141c07af40b1b5ee71c28c5a6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: