Exemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            GUILayout.Space(10);

            //button to show if hit targets
            if (GUILayout.Button("Update Targets"))
            {
                FieldOfView2D fov = (FieldOfView2D)target;
                fov.FindVisibleTargets();

                //repaint scene
                SceneView.RepaintAll();
            }
        }
Exemplo n.º 2
0
        void OnSceneGUI()
        {
            //draw circle
            FieldOfView2D fov = (FieldOfView2D)target;

            Handles.color = Color.white;
            Handles.DrawWireArc(fov.transform.position, Vector3.back, fov.StartDirection, 360, fov.viewRadius);

            //draw 2 line to see cone vision
            Vector3 ViewAngleA = fov.DirFromAngle(-fov.viewAngle / 2, false);
            Vector3 ViewAngleB = fov.DirFromAngle(fov.viewAngle / 2, false);

            Handles.DrawLine(fov.transform.position, fov.transform.position + ViewAngleA * fov.viewRadius);
            Handles.DrawLine(fov.transform.position, fov.transform.position + ViewAngleB * fov.viewRadius);

            //show targets
            Handles.color = Color.red;
            foreach (Transform visibleTarget in fov.VisibleTargets)
            {
                Handles.DrawLine(fov.transform.position, visibleTarget.position);
            }
        }