1
1
using UnityEngine ;
2
2
using UnityEditor ;
3
3
using System . Collections . Generic ;
4
+ using Cinemachine . Utility ;
4
5
5
6
namespace Cinemachine . Editor
6
7
{
7
8
[ CustomEditor ( typeof ( CinemachineBrain ) ) ]
8
- internal sealed class CinemachineBrainEditor : UnityEditor . Editor
9
+ internal sealed class CinemachineBrainEditor : BaseEditor < CinemachineBrain >
9
10
{
10
- private CinemachineBrain Target { get { return target as CinemachineBrain ; } }
11
- EmbeddeAssetEditor < CinemachineBlenderSettings > m_SettingsEditor ;
12
-
11
+ EmbeddeAssetEditor < CinemachineBlenderSettings > m_BlendsEditor ;
13
12
bool mEventsExpanded = false ;
14
13
14
+ protected override List < string > GetExcludedPropertiesInInspector ( )
15
+ {
16
+ List < string > excluded = base . GetExcludedPropertiesInInspector ( ) ;
17
+ excluded . Add ( FieldPath ( x => x . m_CameraCutEvent ) ) ;
18
+ excluded . Add ( FieldPath ( x => x . m_CameraActivatedEvent ) ) ;
19
+ excluded . Add ( FieldPath ( x => x . m_CustomBlends ) ) ;
20
+ return excluded ;
21
+ }
22
+
15
23
private void OnEnable ( )
16
24
{
17
- m_SettingsEditor = new EmbeddeAssetEditor < CinemachineBlenderSettings > (
18
- SerializedPropertyHelper . PropertyName ( ( ) => Target . m_CustomBlends ) , this ) ;
19
- m_SettingsEditor . OnChanged = ( CinemachineBlenderSettings b ) =>
25
+ m_BlendsEditor = new EmbeddeAssetEditor < CinemachineBlenderSettings > (
26
+ FieldPath ( x => x . m_CustomBlends ) , this ) ;
27
+ m_BlendsEditor . OnChanged = ( CinemachineBlenderSettings b ) =>
20
28
{
21
29
UnityEditorInternal . InternalEditorUtility . RepaintAllViews ( ) ;
22
30
} ;
23
31
}
24
32
25
33
private void OnDisable ( )
26
34
{
27
- if ( m_SettingsEditor != null )
28
- m_SettingsEditor . OnDisable ( ) ;
35
+ if ( m_BlendsEditor != null )
36
+ m_BlendsEditor . OnDisable ( ) ;
29
37
}
30
38
31
39
public override void OnInspectorGUI ( )
32
40
{
33
- serializedObject . Update ( ) ;
41
+ BeginInspector ( ) ;
34
42
35
43
// Show the active camera and blend
36
44
GUI . enabled = false ;
@@ -44,24 +52,19 @@ public override void OnInspectorGUI()
44
52
GUI . enabled = true ;
45
53
46
54
// Normal properties
47
- List < string > excludeFields = new List < string >
48
- {
49
- "m_Script" ,
50
- SerializedPropertyHelper . PropertyName ( ( ) => Target . m_CameraCutEvent ) ,
51
- SerializedPropertyHelper . PropertyName ( ( ) => Target . m_CameraActivatedEvent )
52
- } ;
53
- DrawPropertiesExcluding ( serializedObject , excludeFields . ToArray ( ) ) ;
55
+ DrawRemainingPropertiesInInspector ( ) ;
54
56
55
- m_SettingsEditor . DrawEditorCombo (
57
+ // Blender
58
+ m_BlendsEditor . DrawEditorCombo (
56
59
"Create New Blender Asset" ,
57
60
Target . gameObject . name + " Blends" , "asset" , string . Empty ,
58
61
"Custom Blends" , false ) ;
59
62
60
63
mEventsExpanded = EditorGUILayout . Foldout ( mEventsExpanded , "Events" ) ;
61
64
if ( mEventsExpanded )
62
65
{
63
- EditorGUILayout . PropertyField ( serializedObject . FindProperty ( ( ) => Target . m_CameraCutEvent ) ) ;
64
- EditorGUILayout . PropertyField ( serializedObject . FindProperty ( ( ) => Target . m_CameraActivatedEvent ) ) ;
66
+ EditorGUILayout . PropertyField ( FindProperty ( x => x . m_CameraCutEvent ) ) ;
67
+ EditorGUILayout . PropertyField ( FindProperty ( x => x . m_CameraActivatedEvent ) ) ;
65
68
}
66
69
serializedObject . ApplyModifiedProperties ( ) ;
67
70
}
@@ -112,5 +115,29 @@ internal static void DrawCameraFrustumGizmo(
112
115
Gizmos . matrix = originalMatrix ;
113
116
Gizmos . color = originalGizmoColour ;
114
117
}
118
+
119
+ [ DrawGizmo ( GizmoType . Active | GizmoType . InSelectionHierarchy | GizmoType . Pickable , typeof ( CinemachineVirtualCameraBase ) ) ]
120
+ internal static void DrawVirtualCameraBaseGizmos ( CinemachineVirtualCameraBase vcam , GizmoType selectionType )
121
+ {
122
+ // Don't draw gizmos on hidden stuff
123
+ if ( ( vcam . VirtualCameraGameObject . hideFlags & ( HideFlags . HideInHierarchy | HideFlags . HideInInspector ) ) != 0 )
124
+ return ;
125
+
126
+ if ( vcam . ParentCamera != null && ( selectionType & GizmoType . Active ) == 0 )
127
+ return ;
128
+
129
+ CameraState state = vcam . State ;
130
+ Gizmos . DrawIcon ( state . FinalPosition , "Cinemachine/cm_logo_lg.png" , true ) ;
131
+
132
+ DrawCameraFrustumGizmo (
133
+ CinemachineCore . Instance . FindPotentialTargetBrain ( vcam ) ,
134
+ state . Lens ,
135
+ Matrix4x4 . TRS (
136
+ state . FinalPosition ,
137
+ UnityQuaternionExtensions . Normalized ( state . FinalOrientation ) , Vector3 . one ) ,
138
+ CinemachineCore . Instance . IsLive ( vcam )
139
+ ? CinemachineSettings . CinemachineCoreSettings . ActiveGizmoColour
140
+ : CinemachineSettings . CinemachineCoreSettings . InactiveGizmoColour ) ;
141
+ }
115
142
}
116
143
}
0 commit comments