Merge branch 'Test-for-letterbox'
This commit is contained in:
commit
2c6f7444d1
|
|
@ -706,7 +706,6 @@ namespace HeavenStudio
|
|||
new Param("axis", StaticCamera.ViewAxis.All, "Axis", "The axis to scale the viewport in" )
|
||||
}
|
||||
),
|
||||
|
||||
new GameAction("screen shake", "Screen Shake", 1f, true,
|
||||
new List<Param>()
|
||||
{
|
||||
|
|
@ -714,6 +713,30 @@ namespace HeavenStudio
|
|||
new Param("valB", new EntityTypes.Float(0, 10, 1), "Vertical Intensity")
|
||||
}
|
||||
),
|
||||
new GameAction("scale letterbox", "Scale Letterbox", 1f, true, new List<Param>()
|
||||
{
|
||||
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 GameAction("complex pan", "Pan Viewport(Complex)", 1f, true, new List<Param>()
|
||||
{
|
||||
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<Param>()
|
||||
{
|
||||
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("ease", Util.EasingFunction.Ease.Linear, "Ease Type"),
|
||||
new Param("axis", StaticCamera.ViewAxis.All, "Axis", "The axis to scale the viewport in")
|
||||
}
|
||||
),
|
||||
|
||||
new GameAction("pan window", "Move Window", 1f, true, new List<Param>()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ namespace HeavenStudio
|
|||
[SerializeField] Image ambientBg;
|
||||
[SerializeField] GameObject ambientBgGO;
|
||||
[SerializeField] GameObject letterboxBgGO;
|
||||
[SerializeField] RectTransform letterboxMask;
|
||||
[SerializeField] RawImage viewportTexture;
|
||||
|
||||
public static StaticCamera instance { get; private set; }
|
||||
public new Camera camera;
|
||||
|
|
@ -37,18 +39,32 @@ namespace HeavenStudio
|
|||
private List<RiqEntity> panEvents = new();
|
||||
private List<RiqEntity> scaleEvents = new();
|
||||
private List<RiqEntity> rotationEvents = new();
|
||||
private List<RiqEntity> letterboxEvents = new();
|
||||
private List<RiqEntity> complexPanEvents = new();
|
||||
private List<RiqEntity> 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;
|
||||
private static float rotation;
|
||||
private static Vector3 letterbox;
|
||||
private static Vector3 panInv;
|
||||
private static Vector3 scaleInv;
|
||||
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()
|
||||
{
|
||||
|
|
@ -64,8 +80,11 @@ namespace HeavenStudio
|
|||
Reset();
|
||||
|
||||
panLast = defaultPan;
|
||||
letterboxLast = defaultLetterbox;
|
||||
scaleLast = defaultScale;
|
||||
rotationLast = defaultRotation;
|
||||
complexPanLast = defaultComplexPan;
|
||||
complexScaleLast = defaultComplexScale;
|
||||
|
||||
ToggleLetterboxBg(PersistentDataManager.gameSettings.letterboxBgEnable);
|
||||
ToggleLetterboxGlow(PersistentDataManager.gameSettings.letterboxFxEnable);
|
||||
|
|
@ -78,26 +97,44 @@ namespace HeavenStudio
|
|||
panEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "pan view" });
|
||||
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
|
||||
void Update()
|
||||
{
|
||||
UpdateLetterbox();
|
||||
UpdatePan();
|
||||
UpdateRotation();
|
||||
UpdateScale();
|
||||
|
||||
UpdateComplexPan();
|
||||
UpdatecomplexScale();
|
||||
|
||||
canvas.localPosition = pan;
|
||||
canvas.eulerAngles = new Vector3(0, 0, rotation);
|
||||
canvas.localScale = scale;
|
||||
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()
|
||||
|
|
@ -199,11 +236,137 @@ namespace HeavenStudio
|
|||
}
|
||||
}
|
||||
|
||||
private void UpdateLetterbox()
|
||||
{
|
||||
foreach (var e in letterboxEvents)
|
||||
{
|
||||
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:
|
||||
letterbox.x = func(letterboxLast.x, e["valA"], Mathf.Min(prog, 1f)) * AspectRatioWidth;
|
||||
break;
|
||||
case (int) ViewAxis.Y:
|
||||
letterbox.y = func(letterboxLast.y, e["valB"], 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;
|
||||
letterbox = new Vector3(dx, dy, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (prog > 1f)
|
||||
{
|
||||
switch (e["axis"])
|
||||
{
|
||||
case (int) ViewAxis.X:
|
||||
letterboxLast.x = e["valA"] * AspectRatioWidth;
|
||||
break;
|
||||
case (int) ViewAxis.Y:
|
||||
letterboxLast.y = e["valB"] * AspectRatioHeight;
|
||||
break;
|
||||
default:
|
||||
letterboxLast = new Vector3(e["valA"] * AspectRatioWidth, e["valB"] * AspectRatioHeight, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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"] * .01f, Mathf.Min(prog, 1f)) * AspectRatioWidth;
|
||||
break;
|
||||
case (int) ViewAxis.Y:
|
||||
complexScale.y = func(complexScaleLast.y, e["valB"] * .01f, 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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (prog > 1f)
|
||||
{
|
||||
switch (e["axis"])
|
||||
{
|
||||
case (int) ViewAxis.X:
|
||||
complexScaleLast.x = e["valA"] * .01f * AspectRatioWidth;
|
||||
break;
|
||||
case (int) ViewAxis.Y:
|
||||
complexScaleLast.y = e["valB"] * .01f * AspectRatioHeight;
|
||||
break;
|
||||
default:
|
||||
complexScaleLast = new Vector3(e["valA"] * .01f * AspectRatioWidth, e["valB"] * .01f * AspectRatioHeight, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Reset()
|
||||
{
|
||||
pan = defaultPan;
|
||||
scale = defaultScale;
|
||||
rotation = defaultRotation;
|
||||
letterbox = defaultLetterbox;
|
||||
complexPan = defaultComplexPan;
|
||||
complexScale = defaultComplexScale;
|
||||
}
|
||||
|
||||
public void ToggleOverlayView(bool toggle)
|
||||
|
|
|
|||
Loading…
Reference in a new issue