This commit is contained in:
CortexCore
2025-02-24 23:02:43 +08:00
parent 41715e4413
commit 8261a458e2
105 changed files with 2934 additions and 696 deletions

View File

@@ -0,0 +1,52 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
namespace BITKit.UX
{
public class CellContainer : VisualElement
{
public new class UxmlFactory : UxmlFactory<CellContainer, UxmlTraits> { }
public int CellSize { get; set; } = 64;
public CellContainer()
{
RegisterCallback<CustomStyleResolvedEvent>(x =>
{
MarkDirtyRepaint();
});
generateVisualContent += GenerateVisualContent;
}
private void GenerateVisualContent(MeshGenerationContext obj)
{
if(contentRect.height<=0 || contentRect.width<=0)return;
var painter = obj.painter2D;
painter.lineWidth = resolvedStyle.borderTopWidth;
painter.strokeColor = resolvedStyle.borderTopColor;
var yCount = contentRect.height / CellSize;
var xCount = contentRect.width / CellSize;
for (var x = 1; x < xCount; x++)
{
painter.BeginPath();
painter.MoveTo(new Vector2(x * CellSize, 0));
painter.LineTo(new Vector2(x * CellSize, contentRect.height));
painter.Stroke();
}
for (var y = 1; y < yCount; y++)
{
painter.BeginPath();
painter.MoveTo(new Vector2(0, y * CellSize));
painter.LineTo(new Vector2(contentRect.width, y * CellSize));
painter.Stroke();
}
}
}
}

View File

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