Support vertical min max linerenderer sample
This commit is contained in:
parent
838ac1d272
commit
74402a8a2a
|
@ -13,6 +13,16 @@ PrefabInstance:
|
||||||
propertyPath: m_Positions.Array.size
|
propertyPath: m_Positions.Array.size
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 639897978325975064, guid: c309e2ab8a7e17f049cee02d2d5e1af3,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_Parameters.widthCurve.m_Curve.Array.data[0].value
|
||||||
|
value: 0.14800072
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1425401315373935596, guid: c309e2ab8a7e17f049cee02d2d5e1af3,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: orientation
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4241178655744724118, guid: c309e2ab8a7e17f049cee02d2d5e1af3,
|
- target: {fileID: 4241178655744724118, guid: c309e2ab8a7e17f049cee02d2d5e1af3,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
|
@ -71,7 +81,7 @@ PrefabInstance:
|
||||||
- target: {fileID: 7730797280345979287, guid: c309e2ab8a7e17f049cee02d2d5e1af3,
|
- target: {fileID: 7730797280345979287, guid: c309e2ab8a7e17f049cee02d2d5e1af3,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_IsActive
|
propertyPath: m_IsActive
|
||||||
value: 0
|
value: 1
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8501533562697966838, guid: c309e2ab8a7e17f049cee02d2d5e1af3,
|
- target: {fileID: 8501533562697966838, guid: c309e2ab8a7e17f049cee02d2d5e1af3,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
public enum ArcOrientation
|
||||||
|
{
|
||||||
|
HORIZONTAL,
|
||||||
|
VERTICAL,
|
||||||
|
}
|
||||||
|
|
||||||
[RequireComponent(typeof(LineRenderer))]
|
[RequireComponent(typeof(LineRenderer))]
|
||||||
public class EditableArc : MonoBehaviour
|
public class EditableArc : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
[SerializeField] private ArcOrientation orientation = ArcOrientation.HORIZONTAL;
|
||||||
[SerializeField, Range(5, 50)] private int samples = 15;
|
[SerializeField, Range(5, 50)] private int samples = 15;
|
||||||
[SerializeField] private float visualRadius = 1f;
|
[SerializeField] private float visualRadius = 1f;
|
||||||
|
|
||||||
|
@ -28,10 +35,28 @@ public class EditableArc : MonoBehaviour
|
||||||
|
|
||||||
private void UpdateArc(float rotation)
|
private void UpdateArc(float rotation)
|
||||||
{
|
{
|
||||||
|
Vector3 normal;
|
||||||
|
Vector3 tangent;
|
||||||
|
|
||||||
|
if (orientation == ArcOrientation.HORIZONTAL)
|
||||||
|
{
|
||||||
|
normal = transform.up;
|
||||||
|
tangent = transform.right;
|
||||||
|
}
|
||||||
|
else if (orientation == ArcOrientation.VERTICAL)
|
||||||
|
{
|
||||||
|
normal = transform.right;
|
||||||
|
tangent = transform.up;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new System.Exception("WTFFFFF HAVE YOU DONE YOU MF!!?");
|
||||||
|
}
|
||||||
|
|
||||||
float angle = rotationMinMax.y - rotationMinMax.x;
|
float angle = rotationMinMax.y - rotationMinMax.x;
|
||||||
float v = (Mathf.PI - Value * Mathf.Deg2Rad) / 2f;
|
float v = (Mathf.PI - Value * Mathf.Deg2Rad) / 2f;
|
||||||
Vector3 start = Quaternion.AngleAxis(rotationMinMax.x, transform.up) * transform.right;
|
Vector3 start = Quaternion.AngleAxis(rotationMinMax.x, normal) * tangent;
|
||||||
Vector3 end = Quaternion.AngleAxis(rotationMinMax.y, transform.up) * transform.right;
|
Vector3 end = Quaternion.AngleAxis(rotationMinMax.y, normal) * tangent;
|
||||||
|
|
||||||
// Sample LineRenderer points
|
// Sample LineRenderer points
|
||||||
lineRenderer.positionCount = samples + 1;
|
lineRenderer.positionCount = samples + 1;
|
||||||
|
|
Loading…
Reference in New Issue