绳子修改
This commit is contained in:
62
Assets/Scripts/ThirdParty/Rope/Rope.Editor.cs
vendored
Normal file
62
Assets/Scripts/ThirdParty/Rope/Rope.Editor.cs
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
using Unity.Collections;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class Rope
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
public struct EditorColors
|
||||
{
|
||||
public Color ropeSegments;
|
||||
public Color simulationParticle;
|
||||
public Color collisionParticle;
|
||||
public Color spawnPointHandle;
|
||||
}
|
||||
|
||||
public static readonly EditorColors Colors = new EditorColors()
|
||||
{
|
||||
ropeSegments = Color.black,
|
||||
simulationParticle = new Color(0.2f, 0.8f, 0.2f, 0.5f),
|
||||
collisionParticle = new Color(1.0f, 0.92f, 0.016f, 0.5f),
|
||||
spawnPointHandle = new Color(0.1f, 0.5f, 0.8f),
|
||||
};
|
||||
|
||||
public void OnDrawGizmos()
|
||||
{
|
||||
if (Application.isPlaying || spawnPoints.Count < 2 || !enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ComputeRealCurve(Allocator.Temp, out Measurements measurements, out NativeArray<float3> points);
|
||||
|
||||
Gizmos.color = Colors.ropeSegments;
|
||||
for (int i = 0; i < points.Length - 1; i++)
|
||||
{
|
||||
Gizmos.DrawLine(points[i], points[i + 1]);
|
||||
}
|
||||
|
||||
if (UnityEditor.Selection.Contains(gameObject))
|
||||
{
|
||||
for (int i = 0; i < points.Length; i++)
|
||||
{
|
||||
if (collisions.enabled && i % collisions.stride == 0)
|
||||
{
|
||||
Gizmos.color = Colors.collisionParticle;
|
||||
}
|
||||
else
|
||||
{
|
||||
Gizmos.color = Colors.simulationParticle;
|
||||
}
|
||||
|
||||
Gizmos.DrawSphere(points[i], radius);
|
||||
}
|
||||
}
|
||||
|
||||
points.Dispose();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user