Esempio n. 1
0
    /// <summary>
    /// Draws an element onto the screen
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="info"></param>
    public static void Draw <T>(Color?color, bool dashed, params object[] args) where T : Drawer
    {
        if (!Enabled || Camera == null)
        {
            return;
        }

        Drawer drawer = Drawer.Get <T>();

        if (drawer != null)
        {
            Vector3[] points = drawer.Draw(args);

            bool notVisible = true;
            for (int i = 0; i < points.Length; i++)
            {
                Vector3 p = Camera.WorldToScreenPoint(points[i]);
                if (p.x > 0 && p.y > 0 && p.x < Screen.width && p.y < Screen.height && p.z > 0)
                {
                    notVisible = false;
                    break;
                }
            }

            if (notVisible)
            {
                return;
            }

            GizmosInstance.Add(points, color, dashed);
        }
    }
Esempio n. 2
0
    /// <summary>
    /// Draws an element onto the screen
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="info"></param>
    public static void Draw <T>(Color?color = null, bool dashed = false, params object[] args) where T : Drawer
    {
        if (!Enabled)
        {
            return;
        }

        Drawer drawer = Drawer.Get <T>();

        if (drawer != null)
        {
            Vector3[] points = drawer.Draw(args);
            GizmosInstance.Add(points, color, dashed);
        }
    }
Esempio n. 3
0
    /// <summary>
    /// Draws an element onto the screen
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="info"></param>
    public static void Draw <T>(Color?color, bool dashed, params object[] args) where T : Drawer
    {
        if (!Enabled)
        {
            return;
        }

        Drawer drawer = Drawer.Get <T>();

        if (drawer != null)
        {
            Camera    currentCamera = GizmosInstance.currentCamera;
            Vector3[] points        = drawer.Draw(args);

            if (Cull)
            {
                bool visible = false;
                for (int i = 0; i < points.Length; i++)
                {
                    //no current camera, assume its visible
                    if (currentCamera == null)
                    {
                        visible = true;
                        break;
                    }

                    //frustrum cull using the current camera
                    Vector3 p = currentCamera.WorldToScreenPoint(points[i]);
                    if (p.x >= 0 && p.y >= 0 && p.x <= Screen.width && p.y <= Screen.height && p.z >= 0)
                    {
                        visible = true;
                        break;
                    }
                }

                if (!visible)
                {
                    return;
                }
            }

            GizmosInstance.Add(points, color, dashed);
        }
    }