示例#1
0
        public override void OnInspectorGUI()
        {
            var oldValue = (T)field.GetValue(target);
            var newValue = EditorGUILayout.ObjectField(oldValue, typeof(T), false);

            if (oldValue != newValue)
            {
                field.SetValue(target, newValue);
                dataEditor = (ComboItemDataEditor <T>)CreateEditor((T)newValue);
                comboItem.OnSettingsChanged();
                Repaint();
            }

            if (dataEditor != null)
            {
                using (var changeScope = new EditorGUI.ChangeCheckScope()) {
                    dataEditor.OnInspectorGUI();
                    if (changeScope.changed)
                    {
                        comboItem.OnSettingsChanged();
                        Repaint();
                    }
                }
            }

            base.OnInspectorGUI();
            serializedObject.ApplyModifiedProperties();
        }
示例#2
0
 protected virtual void OnEnable()
 {
     comboItem  = (ComboItem <T>)target;
     field      = typeof(ComboItem <T>).GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
     dataEditor = field != null
         ? (ComboItemDataEditor <T>)CreateEditor((T)field.GetValue(target))
         : null;
     comboItem.OnSettingsChanged();
     Tools.hidden = true;
 }