コード例 #1
0
        private void DisplaySelectedStatContent(RPGStatAsset stat)
        {
            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            var statType = RPGStatTypeDatabase.Instance.Get(stat.AssignedStatId, true);

            GUILayout.Label(string.Format("[{0}]: {1}", stat.CreateInstance().GetType().Name,
                                          statType == null ? "Stat Type Not Set" : statType.Name));

            if (GUILayout.Button(statType == null ? "Assign Type" : "Change Type", EditorStyles.toolbarButton, GUILayout.Width(100)))
            {
                XmlDatabaseEditorUtility.ShowContext(RPGStatTypeDatabase.Instance, (statTypeAsset) => {
                    stat.AssignedStatId = statTypeAsset.Id;
                    Debug.Log("Assigning stat to stat type " + statTypeAsset.Id);
                }, typeof(RPGStatTypeWindow));
            }
            GUILayout.EndHorizontal();

            if (stat != null)
            {
                foreach (var extension in RPGStatEditorUtility.GetExtensions())
                {
                    if (extension.CanHandleType(stat.GetType()))
                    {
                        extension.OnGUI(stat);
                    }
                }
            }

            GUILayout.EndVertical();
        }
コード例 #2
0
        private void DisplayStatSelectionFooter()
        {
            var selectedCollection = RPGStatCollectionDatabase.Instance.Get(SelectedAssetId, true);

            if (selectedCollection != null)
            {
                GUILayout.BeginHorizontal(GUILayout.Width(200));
                if (GUILayout.Button("+", EditorStyles.toolbarButton))
                {
                    XmlDatabaseEditorUtility.GetGenericMenu(RPGStatEditorUtility.GetNames(), (index) => {
                        var statAsset = RPGStatEditorUtility.CreateAsset(index);
                        selectedCollection.Stats.Add(statAsset);

                        //info.StatAsset.statName = RPGStatTypeDatabase.GetAsset(info.StatTypeId).Name;

                        SelectedStatIndex = selectedCollection.Stats.Count - 1;
                        EditorWindow.FocusWindowIfItsOpen <RPGStatCollectionWindow>();
                    }).ShowAsContext();
                }
                if (GUILayout.Button("-", EditorStyles.toolbarButton) &&
                    EditorUtility.DisplayDialog("Delete Stat", "Are you sure you want to delete the " +
                                                "selected stat?", "Delete", "Cancel"))
                {
                    if (SelectedStatIndex >= 0 && SelectedStatIndex < selectedCollection.Stats.Count)
                    {
                        selectedCollection.Stats.RemoveAt(SelectedStatIndex--);
                        if (SelectedStatIndex == -1 && selectedCollection.Stats.Count > 0)
                        {
                            SelectedStatIndex = 0;
                        }
                    }
                }
                GUILayout.Label("", EditorStyles.toolbarButton, GUILayout.Width(15));
                GUILayout.EndHorizontal();
            }
        }