Exemple #1
0
        /// <summary>
        /// Draws the attributes list.
        /// </summary>
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            EditorGUI.BeginChangeCheck();
            ReorderableListSerializationHelper.DrawReorderableList(ref m_ReorderableAttributeList, this, m_AttributeManager.Attributes, "m_Attributes",
                                                                   OnAttributeListDrawHeader, OnAttributeListDraw, null, OnAttributeListAdd, OnAttributeListRemove, OnAttributeListSelect,
                                                                   DrawSelectedAttribute, SelectedAttributeIndexKey, false, false);
            if (EditorGUI.EndChangeCheck())
            {
                InspectorUtility.RecordUndoDirtyObject(target, "Change Value");
                serializedObject.ApplyModifiedProperties();
            }
        }
        /// <summary>
        /// Returns the actions to draw before the State list is drawn.
        /// </summary>
        /// <returns>The actions to draw before the State list is drawn.</returns>
        protected override Action GetDrawCallback()
        {
            var baseCallback = base.GetDrawCallback();

            baseCallback += () =>
            {
                EditorGUILayout.PropertyField(PropertyFromName("m_TrailLocation"));
                if (Foldout("Hitboxes"))
                {
                    EditorGUI.indentLevel++;
                    ReorderableListSerializationHelper.DrawReorderableList(ref m_ReorderableHitboxList, this, m_MeleeWeaponProperties.Hitboxes, "m_Hitboxes",
                                                                           HitboxInspector.OnHitboxHeaderDraw, OnHitboxListDraw, null, OnHitboxListAdd, OnHitboxListRemove, OnHitboxListSelect,
                                                                           DrawSelectedHitbox, SelectedHitboxIndexKey, false, true);
                    EditorGUI.indentLevel--;
                }
            };

            return(baseCallback);
        }
Exemple #3
0
        /// <summary>
        /// Returns the actions to draw before the State list is drawn.
        /// </summary>
        /// <returns>The actions to draw before the State list is drawn.</returns>
        protected override Action GetDrawCallback()
        {
            var baseCallback = base.GetDrawCallback();

            baseCallback += () =>
            {
                if (Foldout("Character"))
                {
                    EditorGUI.indentLevel++;
                    var initOnAwake = PropertyFromName("m_InitCharacterOnAwake");
                    EditorGUILayout.PropertyField(initOnAwake);
                    if (initOnAwake.boolValue || Application.isPlaying)
                    {
                        var characterProperty = PropertyFromName("m_Character");
                        EditorGUILayout.PropertyField(characterProperty);
                        if (!Application.isPlaying && characterProperty.objectReferenceValue != null)
                        {
                            if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(characterProperty.objectReferenceValue)))
                            {
                                EditorGUILayout.HelpBox("The Camera Controller Character property cannot point to a prefab.", MessageType.Error);
                            }
                        }
                    }

                    var autoAnchorProperty = PropertyFromName("m_AutoAnchor");
                    EditorGUILayout.PropertyField(autoAnchorProperty);
                    if (autoAnchorProperty.boolValue)
                    {
                        EditorGUILayout.PropertyField(PropertyFromName("m_AutoAnchorBone"));
                    }
                    else
                    {
                        var anchorProperty = PropertyFromName("m_Anchor");
                        anchorProperty.objectReferenceValue = EditorGUILayout.ObjectField("Anchor", anchorProperty.objectReferenceValue, typeof(Transform), true, GUILayout.MinWidth(80)) as Transform;
                        if (anchorProperty.objectReferenceValue == null)
                        {
                            EditorGUILayout.HelpBox("The anchor specifies the Transform that the camera should follow. If null it will use the Character's Transform.", MessageType.Info);
                        }
                    }
                    EditorGUILayout.PropertyField(PropertyFromName("m_AnchorOffset"));

                    EditorGUI.indentLevel--;
                }

                if (Foldout("View Types"))
                {
                    EditorGUILayout.BeginVertical("Box");
                    EditorGUI.indentLevel++;
                    // Only show the first/third person view type popup if that view type is available.
                    if (!string.IsNullOrEmpty(m_CameraController.FirstPersonViewTypeFullName) && !string.IsNullOrEmpty(m_CameraController.ThirdPersonViewTypeFullName))
                    {
                        var selectedIndex = 0;
                        for (int i = 0; i < m_FirstPersonViewTypes.Length; ++i)
                        {
                            if (m_FirstPersonViewTypes[i].FullName == m_CameraController.FirstPersonViewTypeFullName)
                            {
                                selectedIndex = i;
                                break;
                            }
                        }
                        var index = EditorGUILayout.Popup("First Person View Type", selectedIndex, m_FirstPersonViewTypeNames);
                        if (index != selectedIndex)
                        {
                            m_CameraController.FirstPersonViewTypeFullName = PropertyFromName("m_FirstPersonViewTypeFullName").stringValue = m_FirstPersonViewTypes[index].FullName;
                            // Update the default view type if the current view type is first person. Do not update when playing because the first person property will update the current type.
                            if (Application.isPlaying && m_CameraController.ActiveViewType.FirstPersonPerspective)
                            {
                                m_CameraController.ViewTypeFullName = m_CameraController.FirstPersonViewTypeFullName;
                            }
                            serializedObject.ApplyModifiedProperties();
                        }
                        for (int i = 0; i < m_ThirdPersonViewTypes.Length; ++i)
                        {
                            if (m_ThirdPersonViewTypes[i].FullName == m_CameraController.ThirdPersonViewTypeFullName)
                            {
                                selectedIndex = i;
                                break;
                            }
                        }
                        index = EditorGUILayout.Popup("Third Person View Type", selectedIndex, m_ThirdPersonViewTypeNames);
                        if (index != selectedIndex)
                        {
                            m_CameraController.ThirdPersonViewTypeFullName = PropertyFromName("m_ThirdPersonViewTypeFullName").stringValue = m_ThirdPersonViewTypes[index].FullName;
                            // Update the default view type if the current view type is third person. Do not update when playing because the third person property will update the current type.
                            if (!Application.isPlaying && !m_CameraController.ActiveViewType.FirstPersonPerspective)
                            {
                                m_CameraController.ViewTypeFullName = m_CameraController.ThirdPersonViewTypeFullName;
                            }
                            serializedObject.ApplyModifiedProperties();
                        }
                        EditorGUILayout.PropertyField(PropertyFromName("m_CanChangePerspectives"));
                    }
                    ReorderableListSerializationHelper.DrawReorderableList(ref m_ReorderableViewTypeList, this, m_CameraController.ViewTypes, "m_ViewTypeData",
                                                                           OnViewTypeListDrawHeader, OnViewTypeListDraw, OnViewTypeListReorder, OnViewTypeListAdd,
                                                                           OnViewTypeListRemove, OnViewTypeListSelect, DrawSelectedViewType, SelectedViewTypeIndexKey, true, true);
                    EditorGUI.indentLevel--;
                    EditorGUILayout.EndVertical();
                }
                if (Foldout("Zoom"))
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(PropertyFromName("m_CanZoom"));
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PropertyField(PropertyFromName("m_ZoomState"));
                    GUILayout.Space(-5);
                    GUI.enabled = !string.IsNullOrEmpty(PropertyFromName("m_ZoomState").stringValue);
                    var appendItemIdentifierNameProperty = PropertyFromName("m_StateAppendItemIdentifierName");
                    appendItemIdentifierNameProperty.boolValue = EditorGUILayout.ToggleLeft(new GUIContent("Append Item", "Should the ItemIdentifier name be appened to the state name?"),
                                                                                            appendItemIdentifierNameProperty.boolValue, GUILayout.Width(110));
                    GUI.enabled = true;
                    EditorGUILayout.EndHorizontal();

                    EditorGUI.indentLevel--;
                }
                if (Foldout("Events"))
                {
                    EditorGUI.indentLevel++;
                    Shared.Editor.Inspectors.Utility.InspectorUtility.UnityEventPropertyField(PropertyFromName("m_OnChangeViewTypesEvent"));
                    Shared.Editor.Inspectors.Utility.InspectorUtility.UnityEventPropertyField(PropertyFromName("m_OnChangePerspectivesEvent"));
                    Shared.Editor.Inspectors.Utility.InspectorUtility.UnityEventPropertyField(PropertyFromName("m_OnZoomEvent"));
                    EditorGUI.indentLevel--;
                }
            };

            return(baseCallback);
        }