hellbound/Assets/Scripts/Managers/Camera/Editor/CameraControllerEditor.cs

38 lines
877 B
C#
Raw Normal View History

2021-11-26 11:16:25 +03:00
using System;
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(CameraController))]
public class CameraControllerEditor : Editor
{
private CameraTypeEnum _selectedType;
private void Awake()
{
_selectedType = CameraTypeEnum.START;
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
if (!Application.isPlaying)
return;
EditorGUILayout.Space();
EditorGUILayout.LabelField("Editor Tools", EditorStyles.boldLabel);
var camera = (CameraController)target;
_selectedType = camera.ActiveCamera.type;
var selected = (CameraTypeEnum)EditorGUILayout.EnumPopup("Active Camera: ", _selectedType);
EditorGUILayout.EndFoldoutHeaderGroup();
if (_selectedType != selected)
{
CameraManager.Activate(selected);
}
}
}