public void Add(Vector3 p1, Vector3 p2)
    {
        DebugLineData data = new DebugLineData();

        data.point.Add(p1);
        data.point.Add(p2);
        _data.Add(data);
    }
Exemple #2
0
    private void ForGizmoWithMagnitudeInternal(DebugLineData lineData)
    {
        Gizmos.color = lineData.color;
        Gizmos.DrawRay(lineData.pos, lineData.direction);
        Vector3 right = Quaternion.LookRotation(lineData.direction) * Quaternion.Euler(0, 180 + lineData.arrowHeadAngle, 0) * new Vector3(0, 0, 1);
        Vector3 left  = Quaternion.LookRotation(lineData.direction) * Quaternion.Euler(0, 180 - lineData.arrowHeadAngle, 0) * new Vector3(0, 0, 1);

        Gizmos.DrawRay(lineData.pos + lineData.direction, right * lineData.arrowHeadLength);
        Gizmos.DrawRay(lineData.pos + lineData.direction, left * lineData.arrowHeadLength);
        Vector3 midPoint  = lineData.pos + 0.5f * lineData.direction + new Vector3(0, 0.1f, 0);
        string  magnitude = lineData.direction.magnitude.ToString();

        Handles.Label(midPoint, magnitude);
    }
Exemple #3
0
    public void ForGizmoWithMagnitude(string key, Vector3 pos, Vector3 direction, Color color, float arrowHeadLength = 0.25f, float arrowHeadAngle = 20.0f)
    {
        DebugLineData lineData = new DebugLineData();

        lineData.drawing         = true;
        lineData.pos             = pos;
        lineData.direction       = direction;
        lineData.color           = color;
        lineData.arrowHeadLength = arrowHeadLength;
        lineData.arrowHeadAngle  = arrowHeadAngle;

        if (!linesToDraw.ContainsKey(key))
        {
            linesToDraw.Add(key, lineData);
        }
        else
        {
            linesToDraw[key] = lineData;
        }
    }
Exemple #4
0
 private void OnDrawGizmos()
 {
     if (linesToDraw != null && linesToDraw.Count > 0)
     {
         foreach (KeyValuePair <string, DebugLineData> lineDataPair in linesToDraw)
         {
             if (lineDataPair.Value.drawing)
             {
                 ForGizmoWithMagnitudeInternal(lineDataPair.Value);
                 keysToUpdate.Add(lineDataPair.Key);
             }
         }
         for (int i = 0; i < keysToUpdate.Count; i++)
         {
             DebugLineData lineData = linesToDraw[keysToUpdate[i]];
             lineData.drawing             = false;
             linesToDraw[keysToUpdate[i]] = lineData;
         }
         if (keysToUpdate.Count > 0)
         {
             keysToUpdate.Clear();
         }
     }
 }