Esempio n. 1
0
        void OnDrawGizmos()
        {
            if (!Application.isPlaying)
            {
                return;
            }
            Gizmos.color = Color.white;
            Vector3[] PolyLine;
            LSBody    body           = this;
            Vector3   TargetPosition = ((MonoBehaviour)body).transform.position;

            //TargetPosition.y += .55f;
            switch (body.Shape)
            {
            case ColliderType.Circle:
                LSEditorUtility.GizmoCircle(TargetPosition, FixedMath.ToFloat(body.Radius));
                break;

            case ColliderType.AABox:
                PolyLine = new Vector3[] {
                    TargetPosition,
                    TargetPosition,
                    TargetPosition,
                    TargetPosition
                };
                float halfWidth  = FixedMath.ToFloat(body.HalfWidth);
                float halfHeight = FixedMath.ToFloat(body.HalfHeight);
                PolyLine [0].x += halfWidth;
                PolyLine [0].z += halfHeight;
                PolyLine [1].x += halfWidth;
                PolyLine [1].z -= halfHeight;
                PolyLine [2].x -= halfWidth;
                PolyLine [2].z -= halfHeight;
                PolyLine [3].x -= halfWidth;
                PolyLine [3].z += halfHeight;
                LSEditorUtility.GizmoPolyLine(PolyLine);
                break;

            case ColliderType.Polygon:
                int VertLength = body.Vertices.Length;
                PolyLine = new Vector3[VertLength];
                for (int i = 0; i < VertLength; i++)
                {
                    PolyLine[i] = body.RealPoints[i].ToVector3(TargetPosition.y);
                }
                LSEditorUtility.GizmoPolyLine(PolyLine);
                break;
            }
        }