コード例 #1
0
        private void DrawpopupStrategyImplementations(SerializedProperty property, GUIContent label)
        {
            if (_propertyField == null)
            {
                return;
            }

            if (_interfaceTypes == null)
            {
                _interfaceTypes = EditorUtils.GetAllOfInterface(_propertyField.FieldType);
            }

            if (_interfaceTypes == null)
            {
                EditorGUILayout.HelpBox("Not found strategy implementations", MessageType.Warning);
                return;
            }

            if (_interfaceNames == null)
            {
                InitializeInterfacesNames();
            }

            if (_strategyFieldValue != null)
            {
                _strategyImplementationIndex = 1 + _interfaceTypes.FindIndex(0, type => type == _strategyFieldValue.GetType());
            }

            var defaultLabelWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 10;
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(label, GetLabelGUIStyle());

            _strategyImplementationIndex = EditorGUILayout.Popup(_strategyImplementationIndex, _interfaceNames);

            EditorGUILayout.EndHorizontal();
            EditorGUIUtility.labelWidth = defaultLabelWidth;
        }