拼ui 一些业务逻辑x实现

This commit is contained in:
FloatGaming
2026-03-19 06:15:09 +08:00
parent f5c6f143c0
commit 49e45ac464
1118 changed files with 246518 additions and 5368 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 1626a55a59eb6c8419d1c2f1644ea79b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 359794
packageName: Easy Chart Lite
packageVersion: 1.0
assetPath: Assets/EasyChart/Scripts/Runtime/Utils/ChartJsonUtils.cs
uploadId: 857482
@@ -0,0 +1,138 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
namespace EasyChart
{
public static class MeshUtils
{
public static void WriteTexturedQuad(MeshGenerationContext context,
float xMin,
float yMin,
float xMax,
float yMax,
Texture texture,
Color tint,
float u0,
float v0,
float u1,
float v1)
{
if (texture == null) return;
var mesh = context.Allocate(4, 6, texture);
mesh.SetNextVertex(new Vertex { position = new Vector3(xMin, yMin, Vertex.nearZ), tint = tint, uv = new Vector2(u0, v0) });
mesh.SetNextVertex(new Vertex { position = new Vector3(xMax, yMin, Vertex.nearZ), tint = tint, uv = new Vector2(u1, v0) });
mesh.SetNextVertex(new Vertex { position = new Vector3(xMax, yMax, Vertex.nearZ), tint = tint, uv = new Vector2(u1, v1) });
mesh.SetNextVertex(new Vertex { position = new Vector3(xMin, yMax, Vertex.nearZ), tint = tint, uv = new Vector2(u0, v1) });
mesh.SetNextIndex(0);
mesh.SetNextIndex(1);
mesh.SetNextIndex(2);
mesh.SetNextIndex(2);
mesh.SetNextIndex(3);
mesh.SetNextIndex(0);
}
public static void WriteTexturedFan(MeshGenerationContext context,
IList<Vector2> points,
Texture texture,
Color tint,
Rect rect,
float u0,
float v0,
float u1,
float v1)
{
if (texture == null) return;
if (points == null || points.Count < 3) return;
int vCount = points.Count;
int iCount = (vCount - 2) * 3;
var mesh = context.Allocate(vCount, iCount, texture);
for (int vi = 0; vi < vCount; vi++)
{
var p = points[vi];
float tx = rect.width > 0f ? (p.x - rect.xMin) / rect.width : 0f;
float ty = rect.height > 0f ? (p.y - rect.yMin) / rect.height : 0f;
float uu = Mathf.Lerp(u0, u1, tx);
float vv = Mathf.Lerp(v0, v1, ty);
mesh.SetNextVertex(new Vertex { position = new Vector3(p.x, p.y, Vertex.nearZ), tint = tint, uv = new Vector2(uu, vv) });
}
for (int tri = 1; tri < vCount - 1; tri++)
{
mesh.SetNextIndex((ushort)0);
mesh.SetNextIndex((ushort)tri);
mesh.SetNextIndex((ushort)(tri + 1));
}
}
public static void WriteTexturedVerticalStrip(MeshGenerationContext context,
IList<Vector2> topVertices,
float bottomY,
Texture texture,
Color tint,
Vector2 tiling,
Vector2 offset,
bool doubleSided = true)
{
if (texture == null) return;
if (topVertices == null || topVertices.Count < 2) return;
int segmentCount = topVertices.Count - 1;
int vertexCount = topVertices.Count * 2;
int indexCount = segmentCount * 6 * (doubleSided ? 2 : 1);
var mesh = context.Allocate(vertexCount, indexCount, texture);
float startX = topVertices[0].x;
float endX = topVertices[topVertices.Count - 1].x;
float rangeX = endX - startX;
if (rangeX <= 0f) rangeX = 1f;
for (int i = 0; i < topVertices.Count; i++)
{
Vector2 topPos = topVertices[i];
Vector2 bottomPos = new Vector2(topPos.x, bottomY);
float u = (topPos.x - startX) / rangeX;
float uu = u * tiling.x + offset.x;
mesh.SetNextVertex(new Vertex
{
position = new Vector3(topPos.x, topPos.y, Vertex.nearZ),
tint = tint,
uv = new Vector2(uu, tiling.y + offset.y)
});
mesh.SetNextVertex(new Vertex
{
position = new Vector3(bottomPos.x, bottomPos.y, Vertex.nearZ),
tint = tint,
uv = new Vector2(uu, offset.y)
});
}
for (int i = 0; i < segmentCount; i++)
{
ushort top1 = (ushort)(i * 2);
ushort bot1 = (ushort)(i * 2 + 1);
ushort top2 = (ushort)((i + 1) * 2);
ushort bot2 = (ushort)((i + 1) * 2 + 1);
// front
mesh.SetNextIndex(top1); mesh.SetNextIndex(bot1); mesh.SetNextIndex(top2);
mesh.SetNextIndex(top2); mesh.SetNextIndex(bot1); mesh.SetNextIndex(bot2);
if (doubleSided)
{
// back
mesh.SetNextIndex(top1); mesh.SetNextIndex(top2); mesh.SetNextIndex(bot1);
mesh.SetNextIndex(top2); mesh.SetNextIndex(bot2); mesh.SetNextIndex(bot1);
}
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 5f1119113316dee44a30c84e82b7be0f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 359794
packageName: Easy Chart Lite
packageVersion: 1.0
assetPath: Assets/EasyChart/Scripts/Runtime/Utils/MeshUtils.cs
uploadId: 857482
@@ -0,0 +1,20 @@
using System;
namespace EasyChart
{
public static class ProPackage
{
private static bool? s_isInstalled;
public static bool IsInstalled
{
get
{
if (s_isInstalled.HasValue) return s_isInstalled.Value;
var t = Type.GetType("EasyChart.Pro.EasyChartProBootstrap, EasyChart.Pro.Runtime");
s_isInstalled = t != null;
return s_isInstalled.Value;
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: dddd256ba0ed5cd4e83e3ce9111fb085
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 359794
packageName: Easy Chart Lite
packageVersion: 1.0
assetPath: Assets/EasyChart/Scripts/Runtime/Utils/ProPackage.cs
uploadId: 857482
@@ -0,0 +1,139 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace EasyChart
{
public static class RangeUtils
{
public static void ResolveAutoRange<T>(IList<T> items,
Func<T, float> selector,
bool autoRange,
float manualMin,
float manualMax,
out float min,
out float max,
bool ignoreNaN = true,
bool ignoreInfinity = true)
{
min = manualMin;
max = manualMax;
if (!autoRange) return;
if (items == null || items.Count == 0) return;
if (selector == null) return;
bool has = false;
float foundMin = float.MaxValue;
float foundMax = float.MinValue;
for (int i = 0; i < items.Count; i++)
{
float v;
try
{
v = selector(items[i]);
}
catch
{
continue;
}
if (ignoreNaN && float.IsNaN(v)) continue;
if (ignoreInfinity && float.IsInfinity(v)) continue;
if (!has)
{
foundMin = foundMax = v;
has = true;
}
else
{
if (v < foundMin) foundMin = v;
if (v > foundMax) foundMax = v;
}
}
if (!has) return;
min = foundMin;
max = foundMax;
}
public static void ResolveAutoRange(IList<Serie> series,
int maxPointsPerSerie,
Func<SeriesData, float> selector,
bool autoRange,
float manualMin,
float manualMax,
out float min,
out float max,
bool ignoreNaN = true,
bool ignoreInfinity = true)
{
min = manualMin;
max = manualMax;
if (!autoRange) return;
if (series == null || series.Count == 0) return;
if (selector == null) return;
bool has = false;
float foundMin = float.MaxValue;
float foundMax = float.MinValue;
for (int si = 0; si < series.Count; si++)
{
var serie = series[si];
if (serie == null || serie.seriesData == null) continue;
int count = Mathf.Min(maxPointsPerSerie, serie.seriesData.Count);
for (int i = 0; i < count; i++)
{
var dp = serie.seriesData[i];
if (dp == null) continue;
float v;
try
{
v = selector(dp);
}
catch
{
continue;
}
if (ignoreNaN && float.IsNaN(v)) continue;
if (ignoreInfinity && float.IsInfinity(v)) continue;
if (!has)
{
foundMin = foundMax = v;
has = true;
}
else
{
if (v < foundMin) foundMin = v;
if (v > foundMax) foundMax = v;
}
}
}
if (!has) return;
min = foundMin;
max = foundMax;
}
public static void ResolveAutoRange(IList<SeriesData> items,
bool autoRange,
float manualMin,
float manualMax,
Func<SeriesData, float> selector,
out float min,
out float max)
{
ResolveAutoRange(items, selector, autoRange, manualMin, manualMax, out min, out max);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 6069a8491d58634458a0926f5c464963
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 359794
packageName: Easy Chart Lite
packageVersion: 1.0
assetPath: Assets/EasyChart/Scripts/Runtime/Utils/RangeUtils.cs
uploadId: 857482