Skip to content

Commit

Permalink
feat: gradation feature
Browse files Browse the repository at this point in the history
close #277, close #66
mob-sakai committed Dec 31, 2024
1 parent e9522d3 commit bbe57df
Showing 8 changed files with 517 additions and 11 deletions.
36 changes: 36 additions & 0 deletions Packages/src/Editor/UIEffectEditor.cs
Original file line number Diff line number Diff line change
@@ -60,6 +60,13 @@ public class UIEffect2Editor : Editor
private SerializedProperty _shadowColor;
private SerializedProperty _shadowColorGlow;

private SerializedProperty _gradationMode;
private SerializedProperty _gradationColor1;
private SerializedProperty _gradationColor2;
private SerializedProperty _gradationGradient;
private SerializedProperty _gradationOffset;
private SerializedProperty _gradationScale;

private bool _expandOthers;
private SerializedProperty _allowExtendVertex;

@@ -115,6 +122,13 @@ private void OnEnable()
_shadowColor = serializedObject.FindProperty("m_ShadowColor");
_shadowColorGlow = serializedObject.FindProperty("m_ShadowColorGlow");

_gradationMode = serializedObject.FindProperty("m_GradationMode");
_gradationColor1 = serializedObject.FindProperty("m_GradationColor1");
_gradationColor2 = serializedObject.FindProperty("m_GradationColor2");
_gradationGradient = serializedObject.FindProperty("m_GradationGradient");
_gradationOffset = serializedObject.FindProperty("m_GradationOffset");
_gradationScale = serializedObject.FindProperty("m_GradationScale");

_allowExtendVertex = serializedObject.FindProperty("m_AllowExtendVertex");
}

@@ -260,6 +274,28 @@ public void DrawProperties()
EditorGUI.indentLevel--;
}

// Gradient
DrawSeparator();
if (DrawHeaderPopup(_gradationMode))
{
EditorGUI.indentLevel++;
switch ((GradationMode)_gradationMode.intValue)
{
case GradationMode.HorizontalGradient:
case GradationMode.VerticalGradient:
EditorGUILayout.PropertyField(_gradationGradient);
break;
default:
EditorGUILayout.PropertyField(_gradationColor1);
EditorGUILayout.PropertyField(_gradationColor2);
break;
}

EditorGUILayout.PropertyField(_gradationOffset);
EditorGUILayout.PropertyField(_gradationScale);
EditorGUI.indentLevel--;
}

DrawSeparator();
_expandOthers = EditorGUILayout.BeginFoldoutHeaderGroup(_expandOthers, "Others");
if (_expandOthers)
13 changes: 13 additions & 0 deletions Packages/src/Runtime/Enums.cs
Original file line number Diff line number Diff line change
@@ -76,6 +76,19 @@ public enum ShadowMode
Mirror
}

public enum GradationMode
{
None = 0,
Horizontal,
HorizontalGradient,
Vertical,
VerticalGradient,
RadialFast,
RadialDetail,
DiagonalToRightBottom,
DiagonalToLeftBottom
}

internal static class BlendTypeConverter
{
public static (BlendMode, BlendMode) Convert(this (BlendType type, BlendMode src, BlendMode dst) self)
101 changes: 101 additions & 0 deletions Packages/src/Runtime/UIEffect.cs
Original file line number Diff line number Diff line change
@@ -144,6 +144,26 @@ public class UIEffect : UIEffectBase
[SerializeField]
protected bool m_ShadowColorGlow = false;

[SerializeField]
protected GradationMode m_GradationMode = GradationMode.None;

[SerializeField]
protected Color m_GradationColor1 = Color.white;

[SerializeField]
protected Color m_GradationColor2 = Color.white;

[SerializeField]
private Gradient m_GradationGradient = new Gradient();

[Range(-1, 1)]
[SerializeField]
protected float m_GradationOffset = 0;

[PowerRange(0.01f, 10, 10)]
[SerializeField]
protected float m_GradationScale = 1;

[SerializeField]
protected bool m_AllowExtendVertex = true;

@@ -597,6 +617,61 @@ public bool shadowGlow
}
}

public GradationMode gradationMode
{
get => m_GradationMode;
set
{
if (m_GradationMode == value) return;
context.gradationMode = m_GradationMode = value;
SetVerticesDirty();
}
}

public Color gradationColor1
{
get => m_GradationColor1;
set
{
if (m_GradationColor1 == value) return;
context.gradationColor1 = m_GradationColor1 = value;
SetVerticesDirty();
}
}

public Color gradationColor2
{
get => m_GradationColor2;
set
{
if (m_GradationColor2 == value) return;
context.gradationColor2 = m_GradationColor2 = value;
SetVerticesDirty();
}
}

public float gradationOffset
{
get => m_GradationOffset;
set
{
if (Mathf.Approximately(m_GradationOffset, value)) return;
context.gradationOffset = m_GradationOffset = value;
SetVerticesDirty();
}
}

public float gradationScale
{
get => m_GradationScale;
set
{
if (Mathf.Approximately(m_GradationScale, value)) return;
context.gradationScale = m_GradationScale = value;
SetVerticesDirty();
}
}

public bool allowExtendVertex
{
get => m_AllowExtendVertex;
@@ -633,6 +708,7 @@ protected override void OnDestroy()
protected override void OnValidate()
{
(m_SrcBlendMode, m_DstBlendMode) = (m_BlendType, m_SrcBlendMode, m_DstBlendMode).Convert();
context?.SetGradationDirty();
base.OnValidate();
}
#endif
@@ -657,6 +733,13 @@ public override void SetMaterialDirty()
});
}

public void SetGradientKeys(GradientColorKey[] colorKeys, GradientAlphaKey[] alphaKeys)
{
m_GradationGradient ??= new Gradient();
m_GradationGradient.SetKeys(colorKeys, alphaKeys);
context?.SetGradationDirty();
}

protected override void UpdateContext(UIEffectContext c)
{
c.toneFilter = m_ToneFilter;
@@ -696,6 +779,12 @@ protected override void UpdateContext(UIEffectContext c)
c.shadowColorFilter = m_ShadowColorFilter;
c.shadowColor = m_ShadowColor;
c.shadowColorGlow = m_ShadowColorGlow;
c.gradationMode = m_GradationMode;
c.gradationColor1 = m_GradationColor1;
c.gradationColor2 = m_GradationColor2;
c.gradationGradient = m_GradationGradient;
c.gradationOffset = m_GradationOffset;
c.gradationScale = m_GradationScale;
c.allowExtendVertex = m_AllowExtendVertex;
}

@@ -730,6 +819,11 @@ public override void SetRate(float rate, UIEffectTweener.CullingMask mask)
{
transitionRate = rate;
}

if (gradationMode != GradationMode.None && 0 < (mask & UIEffectTweener.CullingMask.Gradiation))
{
gradationOffset = Mathf.Lerp(-1f, 1f, rate);
}
}

public override bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera)
@@ -852,6 +946,13 @@ internal void CopyFrom(UIEffectContext c)
m_ShadowColor = c.shadowColor;
m_ShadowColorGlow = c.shadowColorGlow;

m_GradationMode = c.gradationMode;
m_GradationColor1 = c.gradationColor1;
m_GradationColor2 = c.gradationColor2;
m_GradationGradient = c.gradationGradient;
m_GradationOffset = c.gradationOffset;
m_GradationScale = c.gradationScale;

m_AllowExtendVertex = c.allowExtendVertex;

UpdateContext(context);
89 changes: 87 additions & 2 deletions Packages/src/Runtime/UIEffectContext.cs
Original file line number Diff line number Diff line change
@@ -175,6 +175,15 @@ public class UIEffectContext
public Color shadowColor;
public bool shadowColorGlow;

public GradationMode gradationMode;
public Color gradationColor1;
public Color gradationColor2;
public Gradient gradationGradient;
public float gradationOffset;
public float gradationScale;
private List<float> _keyTimes;
private List<float> _splitTimes;

public bool allowExtendVertex;


@@ -188,6 +197,7 @@ public class UIEffectContext

public void Reset()
{
InternalListPool<float>.Return(ref _keyTimes);
CopyFrom(s_DefaultContext);
}

@@ -237,9 +247,21 @@ public void CopyFrom(UIEffectContext preset)
shadowColor = preset.shadowColor;
shadowColorGlow = preset.shadowColorGlow;

gradationMode = preset.gradationMode;
gradationColor1 = preset.gradationColor1;
gradationColor2 = preset.gradationColor2;
gradationGradient = preset.gradationGradient;
gradationOffset = preset.gradationOffset;
gradationScale = preset.gradationScale;

allowExtendVertex = preset.allowExtendVertex;
}

public void SetGradationDirty()
{
InternalListPool<float>.Return(ref _keyTimes);
}

public void ApplyToMaterial(Material material, float actualSamplingScale = 1f)
{
if (!material) return;
@@ -353,6 +375,7 @@ public void ModifyMesh(Graphic graphic, RectTransform transitionRoot, VertexHelp
// Get the rectangle to calculate the normalized position.
vh.GetUIVertexStream(verts);
var bundleSize = isText ? 6 : count;
var rectMatrix = Matrix4x4.identity;
var rot = Matrix4x4.Rotate(Quaternion.Euler(0, 0, transitionRotation));
var v1 = rot.MultiplyPoint3x4(new Vector3(1, 1, 0));
var multiplier = Mathf.Max(Mathf.Abs(v1.x), Mathf.Abs(v1.y));
@@ -361,9 +384,10 @@ public void ModifyMesh(Graphic graphic, RectTransform transitionRoot, VertexHelp
if (transitionRoot)
{
rect = transitionRoot.rect;
rectMatrix = transitionRoot.worldToLocalMatrix
* graphic.transform.localToWorldMatrix;
rot *= Matrix4x4.Scale(new Vector3(1 / multiplier, 1 / multiplier, 1))
* transitionRoot.worldToLocalMatrix
* graphic.rectTransform.localToWorldMatrix;
* rectMatrix;
}
else
{
@@ -401,13 +425,74 @@ public void ModifyMesh(Graphic graphic, RectTransform transitionRoot, VertexHelp
}
}

// Apply gradation.
ApplyGradation(verts, transitionRoot.rect, rectMatrix);

// Apply shadow.
ApplyShadow(transitionRoot, verts);

vh.Clear();
vh.AddUIVertexTriangleStream(verts);
}

private void ApplyGradation(List<UIVertex> verts, Rect rect, Matrix4x4 m)
{
var a = gradationColor1;
var b = gradationColor2;
var offset = gradationOffset;
var scale = gradationScale;
var grad = gradationGradient;
switch (gradationMode)
{
case GradationMode.Horizontal:
GradientUtil.DoHorizontalGradient(verts, a, b, offset, scale, rect, m);
break;
case GradationMode.Vertical:
GradientUtil.DoVerticalGradient(verts, a, b, offset, scale, rect, m);
break;
case GradationMode.DiagonalToRightBottom:
GradientUtil.DoDiagonalGradientToRightBottom(verts, a, b, offset, scale, rect, m);
break;
case GradationMode.DiagonalToLeftBottom:
GradientUtil.DoDiagonalGradientToLeftBottom(verts, a, b, offset, scale, rect, m);
break;
case GradationMode.RadialFast:
GradientUtil.DoRadialGradient(verts, a, b, offset, scale, rect, m, 4);
break;
case GradationMode.RadialDetail:
GradientUtil.DoRadialGradient(verts, a, b, offset, scale, rect, m, 12);
break;
case GradationMode.HorizontalGradient:
{
if (_keyTimes == null)
{
_keyTimes = InternalListPool<float>.Rent();
GradientUtil.GetKeyTimes(grad, _keyTimes);
}

var splitTimes = InternalListPool<float>.Rent();
GradientUtil.SplitKeyTimes(_keyTimes, splitTimes, offset, scale);
GradientUtil.DoHorizontalGradient(verts, grad, splitTimes, offset, scale, rect, m);
InternalListPool<float>.Return(ref splitTimes);
break;
}
case GradationMode.VerticalGradient:
{
if (_keyTimes == null)
{
_keyTimes = InternalListPool<float>.Rent();
GradientUtil.GetKeyTimes(grad, _keyTimes);
}

var splitTimes = InternalListPool<float>.Rent();
GradientUtil.SplitKeyTimes(_keyTimes, splitTimes, offset, scale);
GradientUtil.DoVerticalGradient(verts, grad, splitTimes, offset, scale, rect, m);
InternalListPool<float>.Return(ref splitTimes);
break;
}
}
}

private void ApplyShadow(RectTransform transitionRoot, List<UIVertex> verts)
{
switch (shadowMode)
3 changes: 2 additions & 1 deletion Packages/src/Runtime/UIEffectTweener.cs
Original file line number Diff line number Diff line change
@@ -14,7 +14,8 @@ public enum CullingMask
Tone = 1 << 0,
Color = 1 << 1,
Sampling = 1 << 2,
Transition = 1 << 3
Transition = 1 << 3,
Gradiation = 1 << 5
}

public enum UpdateMode
259 changes: 259 additions & 0 deletions Packages/src/Runtime/Utilities/GradientUtil.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
using System.Collections.Generic;
using UnityEngine;

namespace Coffee.UIEffects
{
internal static class GradientUtil
{
public static void DoHorizontalGradient(List<UIVertex> verts, Color a, Color b, float offset, float scale,
Rect rect, Matrix4x4 m)
{
for (var i = 0; i < verts.Count; i++)
{
var vt = verts[i];
var x = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(vt.position).x);
var t = Mathf.Clamp01(offset + (x - 0.5f) * scale + 0.5f);
vt.color *= Color.Lerp(a, b, t);
verts[i] = vt;
}
}

public static void DoHorizontalGradient(List<UIVertex> verts, Gradient gradient, List<float> splitTimes,
float offset, float scale, Rect rect, Matrix4x4 m)
{
var count = verts.Count;
for (var i = 0; i < verts.Count; i += 6)
{
UIVertexUtil.GetQuad(verts, i, out var lb, out var lt, out var rt, out var rb);
if (i + 5 < count)
{
UIVertexUtil.SplitHorizontal(verts, splitTimes, lb, lt, ref rb, ref rt, rect, m);
}

lb.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(lb.position).x + 0.0005f, offset, scale);
lt.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(lt.position).x + 0.0005f, offset, scale);
rt.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(rt.position).x - 0.0005f, offset, scale);
rb.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(rb.position).x - 0.0005f, offset, scale);
UIVertexUtil.SetQuad(verts, i, lb, lt, rt, rb);
}

return;

static Color Evaluate(Gradient gradient, Rect rect, float t, float offset, float scale)
{
t = Mathf.InverseLerp(rect.xMin, rect.xMax, t); // 0-1
t = Mathf.Repeat((t - offset * scale - (1 - scale) / 2) / scale, 1); // Revert
return gradient.Evaluate(t);
}
}

public static void DoVerticalGradient(List<UIVertex> verts, Color a, Color b, float offset, float scale,
Rect rect, Matrix4x4 m)
{
for (var i = 0; i < verts.Count; i++)
{
var vt = verts[i];
var y = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(vt.position).y);
var t = Mathf.Clamp01(offset + (0.5f - y) * scale + 0.5f);
vt.color *= Color.Lerp(a, b, t);
verts[i] = vt;
}
}

public static void DoVerticalGradient(List<UIVertex> verts, Gradient gradient, List<float> splitTimes,
float offset, float scale, Rect rect, Matrix4x4 m)
{
var count = verts.Count;
for (var i = 0; i < verts.Count; i += 6)
{
UIVertexUtil.GetQuad(verts, i, out var lb, out var lt, out var rt, out var rb);
if (i + 5 < count)
{
UIVertexUtil.SplitVertical(verts, splitTimes, lb, ref lt, rb, ref rt, rect, m);
}

lb.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(lb.position).y + 0.0005f, offset, scale);
lt.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(lt.position).y - 0.0005f, offset, scale);
rt.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(rt.position).y - 0.0005f, offset, scale);
rb.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(rb.position).y + 0.0005f, offset, scale);
UIVertexUtil.SetQuad(verts, i, lb, lt, rt, rb);
}

return;

static Color Evaluate(Gradient gradient, Rect rect, float t, float offset, float scale)
{
t = Mathf.InverseLerp(rect.yMin, rect.yMax, t); // 0-1
t = Mathf.Repeat((t - offset * scale - (1 - scale) / 2) / scale, 1); // Revert
return gradient.Evaluate(t);
}
}

public static void DoDiagonalGradientToRightBottom(List<UIVertex> verts, Color a, Color b, float offset,
float scale, Rect rect, Matrix4x4 m)
{
for (var i = 0; i < verts.Count; i++)
{
var vt = verts[i];
var x = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(vt.position).x);
var y = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(vt.position).y);
var t = Mathf.Clamp01(0.5f * scale + 0.5f + offset - (1 - x + y) * scale / 2);
vt.color *= Color.Lerp(a, b, t);
verts[i] = vt;
}
}

public static void DoDiagonalGradientToLeftBottom(List<UIVertex> verts, Color a, Color b, float offset,
float scale, Rect rect, Matrix4x4 m)
{
for (var i = 0; i < verts.Count; i++)
{
var vt = verts[i];
var x = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(vt.position).x);
var y = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(vt.position).y);
var t = Mathf.Clamp01(0.5f * scale + 0.5f + offset - (x + y) * scale / 2);
vt.color *= Color.Lerp(a, b, t);
verts[i] = vt;
}
}

public static void DoRadialGradient(List<UIVertex> verts, Color a, Color b, float offset, float scale,
Rect rect, Matrix4x4 m, int divide)
{
var count = verts.Count;
for (var i = 0; i < count; i += 6)
{
UIVertexUtil.GetQuad(verts, i, out var lb, out var lt, out var rt, out var rb);
for (var j = 1; j < divide; j++)
{
var min = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(lb.position).x);
var max = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(rt.position).x);
var time = 1f - (float)j / divide;
if (time <= min || max <= time) continue;

UIVertexUtil.SplitHorizontal(verts, lb, lt, ref rb, ref rt, Mathf.InverseLerp(min, max, time));
}

UIVertexUtil.SetQuad(verts, i, lb, lt, rt, rb);
}

count = verts.Count;
for (var i = 0; i < verts.Count; i += 6)
{
UIVertexUtil.GetQuad(verts, i, out var lb, out var lt, out var rt, out var rb);

if (i + 5 < count)
{
for (var j = 1; j < divide; j++)
{
var min = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(lb.position).y);
var max = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(rt.position).y);
var time = 1f - (float)j / divide;
if (time <= min || max <= time) continue;

UIVertexUtil.SplitVertical(verts, lb, ref lt, rb, ref rt, Mathf.InverseLerp(min, max, time));
}
}

lb.color *= DoGradient(lb, a, b, rect, m, offset, scale);
lt.color *= DoGradient(lt, a, b, rect, m, offset, scale);
rt.color *= DoGradient(rt, a, b, rect, m, offset, scale);
rb.color *= DoGradient(rb, a, b, rect, m, offset, scale);
UIVertexUtil.SetQuad(verts, i, lb, lt, rt, rb);
}

return;

static Color DoGradient(UIVertex vt, Color a, Color b, Rect rect, Matrix4x4 m, float offset, float scale)
{
var x = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(vt.position).x) - 0.5f;
var y = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(vt.position).y) - 0.5f;
var t = Mathf.Clamp01(offset + Mathf.Sqrt(x * x + y * y) * 2 * scale);
return Color.Lerp(a, b, t);
}
}

public static void GetKeyTimes(Gradient gradient, List<float> results)
{
results.Clear();
var colors = gradient.colorKeys;
for (var i = 0; i < colors.Length; i++)
{
AddKeyTime(results, colors[i].time);
}

var alphas = gradient.alphaKeys;
for (var i = 0; i < alphas.Length; i++)
{
AddKeyTime(results, alphas[i].time);
}

AddKeyTime(results, 0);
AddKeyTime(results, 1);
results.Sort((a, b) => b.CompareTo(a));

return;

static void AddKeyTime(List<float> results, float time)
{
if (!Contains(results, time))
{
results.Add(time);
}
}

static bool Contains(List<float> list, float v)
{
for (var i = 0; i < list.Count; i++)
{
if (Mathf.Abs(list[i] - v) < 0.001f) return true;
}

return false;
}
}

public static void SplitKeyTimes(List<float> keyTimes, List<float> results, float offset, float scale)
{
results.Clear();
for (var i = 0; i < keyTimes.Count; i++)
{
AddSplitTime(results, keyTimes[i], offset, scale);
}

results.Sort((a, b) => b.CompareTo(a));

return;

static void AddSplitTime(List<float> results, float time, float offset, float scale)
{
time = time * scale + offset * scale + (1 - scale) / 2;

while (0 < time)
{
time -= scale;
}

while (time < 1f)
{
if (0 < time && !Contains(results, time))
{
results.Add(time);
}

time += scale;
}
}

static bool Contains(List<float> list, float v)
{
for (var i = 0; i < list.Count; i++)
{
if (Mathf.Abs(list[i] - v) < 0.001f) return true;
}

return false;
}
}
}
}
11 changes: 11 additions & 0 deletions Packages/src/Runtime/Utilities/GradientUtil.cs.meta
16 changes: 8 additions & 8 deletions Packages/src/Runtime/Utilities/UIVertexUtil.cs
Original file line number Diff line number Diff line change
@@ -143,18 +143,18 @@ public static void SetQuad(List<UIVertex> verts, int i, UIVertex lb, UIVertex lt
verts[i + 4] = rb;
}

public static void SplitHorizontal(List<UIVertex> verts, UIVertex lb, UIVertex lt, ref UIVertex rb,
ref UIVertex rt, Rect rect, List<float> times)
public static void SplitHorizontal(List<UIVertex> verts, List<float> times, UIVertex lb, UIVertex lt,
ref UIVertex rb, ref UIVertex rt, Rect rect, Matrix4x4 m)
{
if (times == null || times.Count == 0) return;

var min = Mathf.InverseLerp(rect.xMin, rect.xMax, lb.position.x);
var min = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(lb.position).x);
for (var i = 0; i < times.Count; i++)
{
var time = times[i];
if (time <= 0 || 1 <= time) continue;

var max = Mathf.InverseLerp(rect.xMin, rect.xMax, rt.position.x);
var max = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(rt.position).x);
if (time <= min || max <= time) continue;

SplitHorizontal(verts, lb, lt, ref rb, ref rt, Mathf.InverseLerp(min, max, time));
@@ -176,16 +176,16 @@ public static void SplitHorizontal(List<UIVertex> verts, UIVertex lb, UIVertex l
rb = mb;
}

public static void SplitVertical(List<UIVertex> verts, UIVertex lb, ref UIVertex lt, UIVertex rb,
ref UIVertex rt, Rect rect, List<float> times)
public static void SplitVertical(List<UIVertex> verts, List<float> times, UIVertex lb, ref UIVertex lt,
UIVertex rb, ref UIVertex rt, Rect rect, Matrix4x4 m)
{
if (times == null || times.Count == 0) return;

var min = Mathf.InverseLerp(rect.yMin, rect.yMax, lb.position.y);
var min = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(lb.position).y);
for (var i = 0; i < times.Count; i++)
{
var time = times[i];
var max = Mathf.InverseLerp(rect.yMin, rect.yMax, rt.position.y);
var max = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(rt.position).y);
if (time <= min || max <= time) continue;

SplitVertical(verts, lb, ref lt, rb, ref rt, Mathf.InverseLerp(min, max, time));

0 comments on commit bbe57df

Please sign in to comment.