protected virtual List <Stat> GetItems(StatDatabase database) { System.Type type = fieldInfo.FieldType; if (typeof(IList).IsAssignableFrom(fieldInfo.FieldType)) { type = Utility.GetElementType(fieldInfo.FieldType); } return(database.items.Where(x => type.IsAssignableFrom(x.GetType())).ToList()); }
protected override void CreateItem(Type type) { Stat item = (Stat)ScriptableObject.CreateInstance(type); item.hideFlags = HideFlags.HideInHierarchy; StatDatabase database = target as StatDatabase; AssetDatabase.AddObjectToAsset(item, target); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); Items.Add(item); Select(item); EditorUtility.SetDirty(target); }
public void OnEnable() { this.m_Database = AssetDatabase.LoadAssetAtPath <StatDatabase>(EditorPrefs.GetString("StatDatabasePath")); if (this.m_Database == null) { string[] guids = AssetDatabase.FindAssets("t:StatDatabase"); if (guids.Length > 0) { string path = AssetDatabase.GUIDToAssetPath(guids[0]); this.m_Database = AssetDatabase.LoadAssetAtPath <StatDatabase>(path); } } toolbarIndex = EditorPrefs.GetInt("StatToolbarIndex"); ResetChildEditors(); }
protected virtual void DoSelection(Rect buttonRect, SerializedProperty property, GUIContent label, Stat 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); }); } }
private void SelectDatabaseButton() { GUIStyle buttonStyle = EditorStyles.objectField; GUIContent buttonContent = new GUIContent(this.m_Database != null ? this.m_Database.name : "Null"); Rect buttonRect = GUILayoutUtility.GetRect(180f, 18f); if (GUI.Button(buttonRect, buttonContent, buttonStyle)) { ObjectPickerWindow.ShowWindow(buttonRect, typeof(StatDatabase), (UnityEngine.Object obj) => { this.m_Database = obj as StatDatabase; ResetChildEditors(); }, () => { StatDatabase db = EditorTools.CreateAsset <StatDatabase>(true); if (db != null) { this.m_Database = db; ResetChildEditors(); } }); } }