39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Splines;
|
|
namespace BITKit
|
|
{
|
|
public class UnityWireSplineCreator : MonoBehaviour,IAction
|
|
{
|
|
public Mesh mesh;
|
|
public SplineContainer container;
|
|
public SplineExtrude extrude;
|
|
// ReSharper disable Unity.PerformanceAnalysis
|
|
[ContextMenu(nameof(Execute))]
|
|
public void Execute()
|
|
{
|
|
UnityEngine.Splines.Spline spline = new();
|
|
var count = 0;
|
|
// foreach (var vertexes in MathE.Combinations(mesh.vertices))
|
|
// {
|
|
// foreach (var vertex in vertexes)
|
|
// {
|
|
// spline.Add(new BezierKnot()
|
|
// {
|
|
// Position = vertex
|
|
// });
|
|
// count++;
|
|
// }
|
|
// }
|
|
foreach (var vertex in mesh.vertices)
|
|
{
|
|
spline.Add(new (vertex));
|
|
count++;
|
|
}
|
|
container.Spline = spline;
|
|
extrude.Rebuild();
|
|
Debug.Log($"已创建{count}个顶点");
|
|
}
|
|
}
|
|
} |