Ejemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (_labelListClassPopup.LabelListTypes.Any())
            {
                if (_labelListClassPopup.Draw(new GUIContent("LabelClass")))
                {
                    _labelListPopup = new LabelListPopup(_labelListClassPopup.SelectedType);
                }

                if (_labelListPopup != null)
                {
                    using (var h = new EditorGUILayout.HorizontalScope())
                    {
                        _labelListPopup.Draw(new GUIContent("labels"));

                        if (GUILayout.Button("Add"))
                        {
                            var label = _labelListPopup.SelectedLabelValue;

                            var initialLabelProp = serializedObject.FindProperty("_constLabels");
                            if (!initialLabelProp.GetArrayElementEnumerable().Any(_p => _p.prop.stringValue == label))
                            {
                                var index = initialLabelProp.arraySize;
                                initialLabelProp.InsertArrayElementAtIndex(index);
                                initialLabelProp.GetArrayElementAtIndex(index).stringValue = label;

                                serializedObject.ApplyModifiedProperties();
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void OnEnable()
        {
            _labelListClassPopup = new LabelListClassPopup(_labelListClassies);

            if (_labelListClassies.Any())
            {
                _labelListPopup = new LabelListPopup(_labelListClassies.First());
            }
            else
            {
                _labelListPopup = null;
            }
        }