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

            GUILayout.Space(10);

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

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

            Handles.color = Color.white;
            Handles.DrawWireArc(fov.transform.position, Vector3.up, 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);
            }
        }