2
0
Fork 0

圆形和扇形可视化支持

master
cd 2 years ago
parent b668070318
commit 44d173d776

@ -1263,11 +1263,6 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z propertyPath: m_LocalEulerAnglesHint.z
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2900688634913248021, guid: a3b5dc6ed38d00b498bf4e8a547cfa36,
type: 3}
propertyPath: InitialModule.startLifetime.scalar
value: 0.2
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a3b5dc6ed38d00b498bf4e8a547cfa36, type: 3} m_SourcePrefab: {fileID: 100100000, guid: a3b5dc6ed38d00b498bf4e8a547cfa36, type: 3}
--- !u!1 &1879270969 --- !u!1 &1879270969
@ -1480,7 +1475,7 @@ PlayableDirector:
m_GameObject: {fileID: 1645380337361164332} m_GameObject: {fileID: 1645380337361164332}
m_Enabled: 1 m_Enabled: 1
serializedVersion: 3 serializedVersion: 3
m_PlayableAsset: {fileID: 11400000, guid: c1797a25beab8924885805980777dd56, type: 2} m_PlayableAsset: {fileID: 11400000, guid: 1c56e66a1df59614383a8ea99af21081, type: 2}
m_InitialState: 0 m_InitialState: 0
m_WrapMode: 2 m_WrapMode: 2
m_DirectorUpdateMode: 1 m_DirectorUpdateMode: 1
@ -1527,13 +1522,13 @@ PlayableDirector:
- key: {fileID: -4750574827767443630, guid: 1c56e66a1df59614383a8ea99af21081, type: 2} - key: {fileID: -4750574827767443630, guid: 1c56e66a1df59614383a8ea99af21081, type: 2}
value: {fileID: 1645380337361164335} value: {fileID: 1645380337361164335}
- key: {fileID: 2359698281133013487, guid: e4774a4e814dded49a1ec154b070dd3d, type: 2} - key: {fileID: 2359698281133013487, guid: e4774a4e814dded49a1ec154b070dd3d, type: 2}
value: {fileID: 1645380337361164332} value: {fileID: 1645380337361164335}
- key: {fileID: -4824941642191393376, guid: 8132180b67c90a04c89a4dfcc47f81f9, type: 2} - key: {fileID: -4824941642191393376, guid: 8132180b67c90a04c89a4dfcc47f81f9, type: 2}
value: {fileID: 5972941309607553105} value: {fileID: 5972941309607553105}
- key: {fileID: -4824941642191393376, guid: dd907a25a9bbb4e4780e7978cce9c563, type: 2} - key: {fileID: -4824941642191393376, guid: dd907a25a9bbb4e4780e7978cce9c563, type: 2}
value: {fileID: 5972941309607553105} value: {fileID: 5972941309607553105}
- key: {fileID: -4750574827767443630, guid: dd907a25a9bbb4e4780e7978cce9c563, type: 2} - key: {fileID: -4750574827767443630, guid: dd907a25a9bbb4e4780e7978cce9c563, type: 2}
value: {fileID: 1645380337361164332} value: {fileID: 1645380337361164335}
- key: {fileID: -4750574827767443630, guid: 47a64edc9a09a3d41b5b399b240429f5, type: 2} - key: {fileID: -4750574827767443630, guid: 47a64edc9a09a3d41b5b399b240429f5, type: 2}
value: {fileID: 1645380337361164335} value: {fileID: 1645380337361164335}
- key: {fileID: -4824941642191393376, guid: 50230db49392e40499149400a6ba78ff, type: 2} - key: {fileID: -4824941642191393376, guid: 50230db49392e40499149400a6ba78ff, type: 2}
@ -1721,7 +1716,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5972941309607553105} m_GameObject: {fileID: 5972941309607553105}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0.45000005, z: 0} m_LocalPosition: {x: 0, y: 0.40625, z: 0}
m_LocalScale: {x: 1, y: 1, z: 2} m_LocalScale: {x: 1, y: 1, z: 2}
m_Children: [] m_Children: []
m_Father: {fileID: 1645380337361164335} m_Father: {fileID: 1645380337361164335}

@ -54,33 +54,51 @@ namespace Game
{ {
var posReal = pos + shape.Offset; var posReal = pos + shape.Offset;
var posRealTop = posReal + Vector3.up * shape.Height; var posRealTop = posReal + Vector3.up * shape.Height;
var posRealMid = posReal + Vector3.up * (shape.Height / 2);
switch (shape.Type) switch (shape.Type)
{ {
case EShapeType.Dot: case EShapeType.Dot:
Debug.DrawLine(posReal + Vector3.left, posReal + Vector3.right, color); DrawShapeCross(posReal, 1, color);
Debug.DrawLine(posReal + Vector3.down, posReal + Vector3.up, color); DrawShapeCenter(posReal, 1, color);
Debug.DrawLine(posReal + Vector3.back, posReal + Vector3.forward, color);
break; break;
case EShapeType.Box: case EShapeType.Box:
shape.ForeachVerticesPair(direction, (v1, v2) => DrawShapeBody(shape, pos, direction, color);
{ break;
Debug.DrawLine(posReal + v1, posReal + v2, color); case EShapeType.Sector:
Debug.DrawLine(posRealTop + v1, posRealTop + v2, color); DrawShapeBody(shape, pos, direction, color);
});
shape.ForeachVertices(direction, v => { Debug.DrawLine(posReal + v, posRealTop + v, color); });
break; break;
case EShapeType.Circle: case EShapeType.Circle:
var r = shape.Radius; DrawShapeBody(shape, pos, direction, color);
var h = shape.Height; DrawShapeCenter(posRealMid, shape.Height / 2, color);
Debug.DrawLine(posReal + Vector3.left * r, posReal + Vector3.right * r, color); DrawShapeCross(posReal, shape.Radius, color);
Debug.DrawLine(posReal + Vector3.back * r, posReal + Vector3.forward * r, color); DrawShapeCross(posRealTop, shape.Radius, color);
Debug.DrawLine(posRealTop + Vector3.left * r, posRealTop + Vector3.right * r, color);
Debug.DrawLine(posRealTop + Vector3.back * r, posRealTop + Vector3.forward * r, color);
Debug.DrawLine(posReal, posRealTop, color);
break; break;
} }
} }
private static void DrawShapeCenter(Vector3 pos, float h, Color color)
{
Debug.DrawLine(pos + Vector3.down * h, pos + Vector3.up * h, color);
}
private static void DrawShapeCross(Vector3 pos, float r, Color color)
{
Debug.DrawLine(pos + Vector3.left * r, pos + Vector3.right * r, color);
Debug.DrawLine(pos + Vector3.back * r, pos + Vector3.forward * r, color);
}
private static void DrawShapeBody(Shape shape, Vector3 pos, Vector3 direction, Color color)
{
var posReal = pos + shape.Offset;
var posRealTop = posReal + Vector3.up * shape.Height;
shape.ForeachVerticesPair(direction, (v1, v2) =>
{
Debug.DrawLine(posReal + v1, posReal + v2, color);
Debug.DrawLine(posRealTop + v1, posRealTop + v2, color);
});
shape.ForeachVertices(direction, v => { Debug.DrawLine(posReal + v, posRealTop + v, color); });
}
public static void Print(params object[] values) public static void Print(params object[] values)
{ {
string text = ""; string text = "";

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization; using UnityEngine.Serialization;
@ -21,6 +22,7 @@ namespace Game
public float SizeY; public float SizeY;
public float Radius; public float Radius;
public float Angle; public float Angle;
private List<Vector3> vertices = new List<Vector3>();
public static Shape NewDot(Vector3 offset) public static Shape NewDot(Vector3 offset)
{ {
@ -94,40 +96,71 @@ namespace Game
return aabb; return aabb;
} }
public void ForeachVertices(Vector3 direction, Action<Vector3> action) public void SetVertices(Vector3 direction)
{ {
var (halfX, halfY) = (SizeX / 2, SizeY / 2); vertices.Clear();
switch (Type)
{
case EShapeType.Circle:
for (var i = 0; i < 360; i += 15)
{
var angle = i * Mathf.Deg2Rad;
var x = Mathf.Cos(angle) * Radius;
var z = Mathf.Sin(angle) * Radius;
vertices.Add(new Vector3(x, 0, z));
}
var up = new Vector3(direction.z, 0, direction.x); break;
var right = new Vector3(direction.x, 0, -direction.z); case EShapeType.Sector:
var rotAdd = Util.Vec3ToRot(direction);
vertices.Add(Vector3.zero);
var vertNum = (int)(Angle / 15);
var anglePerVertex = Angle / vertNum;
for (var i = 0; i <= vertNum; i++)
{
var angle = (i * anglePerVertex + rotAdd - Angle / 2) * Mathf.Deg2Rad;
var x = Mathf.Cos(angle) * Radius;
var z = Mathf.Sin(angle) * Radius;
vertices.Add(new Vector3(x, 0, z));
}
var topLeft = right * halfX - up * halfY; break;
var topRight = right * halfX + up * halfY; case EShapeType.Box:
var bottomLeft = -right * halfX - up * halfY; var (halfX, halfY) = (SizeX / 2, SizeY / 2);
var bottomRight = -right * halfX + up * halfY;
var up = new Vector3(direction.z, 0, direction.x);
var right = new Vector3(direction.x, 0, -direction.z);
var topLeft = right * halfX - up * halfY;
var topRight = right * halfX + up * halfY;
var bottomLeft = -right * halfX - up * halfY;
var bottomRight = -right * halfX + up * halfY;
vertices.Add(topLeft);
vertices.Add(topRight);
vertices.Add(bottomLeft);
vertices.Add(bottomRight);
break;
}
}
action(topLeft); public void ForeachVertices(Vector3 direction, Action<Vector3> action)
action(topRight); {
action(bottomLeft); SetVertices(direction);
action(bottomRight); foreach (var item in vertices)
{
action(item);
}
} }
public void ForeachVerticesPair(Vector3 direction, Action<Vector3, Vector3> action) public void ForeachVerticesPair(Vector3 direction, Action<Vector3, Vector3> action)
{ {
var (halfX, halfY) = (SizeX / 2, SizeY / 2); SetVertices(direction);
for (var i = 0; i < vertices.Count; i++)
var up = new Vector3(direction.z, 0, direction.x); {
var right = new Vector3(direction.x, 0, -direction.z); var next = i + 1;
if (next >= vertices.Count) next = 0;
var topLeft = right * halfX - up * halfY; action(vertices[i], vertices[next]);
var topRight = right * halfX + up * halfY; }
var bottomLeft = -right * halfX - up * halfY;
var bottomRight = -right * halfX + up * halfY;
action(topLeft, topRight);
action(topRight, bottomRight);
action(bottomRight, bottomLeft);
action(bottomLeft, topLeft);
} }
} }
} }

@ -334,7 +334,7 @@ MonoBehaviour:
m_Start: 0.21666666666666667 m_Start: 0.21666666666666667
m_ClipIn: 0 m_ClipIn: 0
m_Asset: {fileID: 4898924959087489963} m_Asset: {fileID: 4898924959087489963}
m_Duration: 0.05 m_Duration: 0.04999999999999999
m_TimeScale: 1 m_TimeScale: 1
m_ParentTrack: {fileID: -4750574827767443630} m_ParentTrack: {fileID: -4750574827767443630}
m_EaseInDuration: 0 m_EaseInDuration: 0
@ -723,6 +723,14 @@ MonoBehaviour:
staggerLevel: 2 staggerLevel: 2
pauseTime: 0.05 pauseTime: 0.05
hitId: 0 hitId: 0
hitType: 0
Type: 2
Offset: {x: 1, y: 0, z: 0}
Height: 2.5
SizeX: 2
SizeY: 2
Radius: 2
Angle: 98.6
--- !u!114 &5178577764301111608 --- !u!114 &5178577764301111608
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1

Loading…
Cancel
Save