Beispiel #1
0
    void OnSceneGUI()
    {
        ViewField target = null;
        ViewField fow    = (ViewField)target;

        Handles.color = Color.white;
        Handles.DrawWireArc(fow.transform.position, Vector3.up, Vector3.forward, 360, fow.viewRadius);
        Vector3 viewAngleA = fow.DirFromAngle(-fow.viewAngle / 2, false);
        Vector3 viewAngleB = fow.DirFromAngle(fow.viewAngle / 2, false);

        Handles.DrawLine(fow.transform.position, fow.transform.position + viewAngleA * fow.viewRadius);
        Handles.DrawLine(fow.transform.position, fow.transform.position + viewAngleB * fow.viewRadius);

        Handles.color = Color.red;
        foreach (Transform visibleTarget in fow.visibleTargets)
        {
            Handles.DrawLine(fow.transform.position, visibleTarget.position);
        }
    }
    private void OnSceneGUI()
    {
        ViewField vw = (ViewField)target;

        Handles.color = new Color(0, 1, 0, (float)0.1);

        Handles.DrawSolidArc(vw.transform.position, Vector3.up, vw.DirFromAngle(-vw.viewAngle / 2),
                             vw.viewAngle, vw.viewRadius);

        Vector3 viewAngleA = vw.DirFromAngle(-vw.viewAngle / 2);
        Vector3 viewAngleB = vw.DirFromAngle(vw.viewAngle / 2);

        Handles.DrawLine(vw.transform.position, vw.transform.position + viewAngleA * vw.viewRadius);
        Handles.DrawLine(vw.transform.position, vw.transform.position + viewAngleB * vw.viewRadius);

        Handles.color = Color.magenta;
        foreach (GameObject obj in vw.collectVisibleObjects())
        {
            Handles.DrawLine(vw.transform.position, obj.transform.position);
        }
    }