weixudong
2020-11-19 69e0fea6c92fd4e153d45e5f26ef89baecf0405a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using UnityEditor;
 
namespace ActionGameFramework.Projectiles.Editor
{
    [CustomEditor(typeof(BallisticProjectile))]
    public class BallisticProjectileEditor : UnityEditor.Editor
    {
        protected SerializedProperty m_FireModeSelector;
        protected SerializedProperty m_StartSpeedSelector;
        protected SerializedProperty m_StartAngleSelector;
        protected SerializedProperty m_ArcPreferenceSelector;
 
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
 
            EditorGUILayout.PropertyField(m_ArcPreferenceSelector);
 
            EditorGUILayout.LabelField("Choose whether FireAtPoint is calculated based on set angle or set velocity.");
            EditorGUILayout.PropertyField(m_FireModeSelector);
 
            if (m_FireModeSelector.enumValueIndex == (int) BallisticFireMode.UseLaunchSpeed)
            {
                EditorGUILayout.PropertyField(m_StartSpeedSelector);
            }
            else
            {
                EditorGUILayout.PropertyField(m_StartAngleSelector);
            }
 
            serializedObject.ApplyModifiedProperties();
        }
 
        void OnEnable()
        {
            m_FireModeSelector = serializedObject.FindProperty("fireMode");
            m_StartAngleSelector = serializedObject.FindProperty("firingAngle");
            m_StartSpeedSelector = serializedObject.FindProperty("startSpeed");
            m_ArcPreferenceSelector = serializedObject.FindProperty("arcPreference");
        }
    }
}