private void OnSceneGUI() { #if UNITY_EDITOR selectedOutsideInfo = target as EnemyOutsideInfo; if (null == selectedOutsideInfo) { return; } //Draw View Distance DrawViewableRect(selectedOutsideInfo); //Draw Recognizable Distance DrawRecognizableRect(selectedOutsideInfo); #endif }
public static void DrawRecognizableRect(EnemyOutsideInfo eOutsideInfo) { Handles.color = new Color(0.7f, 0f, 0f, 0.05f); Handles.DrawSolidArc( eOutsideInfo.actor.transform.position, Vector3.up, eOutsideInfo.lookDirection, eOutsideInfo.viewAngle * 0.5f, eOutsideInfo.viewRecognizeDistance); Handles.DrawSolidArc( eOutsideInfo.actor.transform.position, Vector3.down, eOutsideInfo.lookDirection, eOutsideInfo.viewAngle * 0.5f, eOutsideInfo.viewRecognizeDistance); var arcPoint = eOutsideInfo.actor.transform.position + eOutsideInfo.lookDirection * eOutsideInfo.viewRecognizeDistance; var size = HandleUtility.GetHandleSize(arcPoint); Handles.color = Color.white; if (Handles.Button(arcPoint, Quaternion.identity, size * handleSize, pickSize, Handles.DotHandleCap)) { selectedIndex = 2; } if (selectedIndex == 2) { EditorGUI.BeginChangeCheck(); arcPoint = Handles.DoPositionHandle(arcPoint, Quaternion.identity); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(eOutsideInfo, "Change Radius"); EditorUtility.SetDirty(eOutsideInfo); eOutsideInfo.lookDirection = (arcPoint - eOutsideInfo.actor.transform.position).normalized; eOutsideInfo.viewRecognizeDistance = Vector3.Distance(eOutsideInfo.transform.position, arcPoint); } } }