public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); StatEffect current = property.GetValue() as StatEffect; position = EditorGUI.PrefixLabel(position, label); DoSelection(position, property, label, current); EditorGUI.EndProperty(); }
public void RemoveEffect(StatEffect effect) { StatEffect instance = this.m_Effects.Find(x => x.Name == effect.Name); this.m_Effects.Remove(instance); }
public void AddEffect(StatEffect effect) { effect = Instantiate(effect); this.m_Effects.Add(effect); effect.Initialize(this); }
protected virtual void DoSelection(Rect buttonRect, SerializedProperty property, GUIContent label, StatEffect current) { GUIStyle buttonStyle = EditorStyles.objectField; GUIContent buttonContent = new GUIContent(current != null ? current.Name : "Null"); if (GUI.Button(buttonRect, buttonContent, buttonStyle)) { ObjectPickerWindow.ShowWindow(buttonRect, typeof(StatDatabase), BuildSelectableObjects(), (UnityEngine.Object obj) => { property.serializedObject.Update(); property.objectReferenceValue = obj; property.serializedObject.ApplyModifiedProperties(); }, () => { StatDatabase db = EditorTools.CreateAsset <StatDatabase>(true); }); } }