Exemple #1
0
        private void Start()
        {
            Stats.Add(new Health(10));
            Stats.Add(new Mana(10));
            Stats.Add(new Strength(10));
            Stats.Add(new Intelligence(10));

            m_inventory.Setup(this);
            m_equipment.Setup(this);
            m_weapons.Setup(this);
            m_statsView.Set(Stats);
        }
        private void DrawStats()
        {
            m_scrollPosition = EditorGUILayout.BeginScrollView(m_scrollPosition, false, false);
            GUILayout.Space(20);
            GUILayout.BeginVertical();

            foreach (var stat in m_stats)
            {
                m_statDrawer.ClassName = Source.GetType().Name;
                m_statDrawer.Source    = stat;
                m_statDrawer.Draw();
            }

            EditorGUILayout.EndScrollView();
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(EditorStyles.toolbar,
                                      GUILayout.ExpandWidth(true),
                                      GUILayout.MaxHeight(22));


            var addIcon = EditorGUIUtility.IconContent("Toolbar Plus More");

            EditorExtension.ClassDropDown <BaseStat>(new GUIContent(addIcon)
                                                     , t => { m_stats?.Add(t); },
                                                     EditorStyles.toolbarButton);

            if (GUILayout.Button(EditorGUIUtility.IconContent("TreeEditor.Trash"),
                                 EditorStyles.toolbarButton))
            {
                m_stats.Clear();
            }

            GUILayout.EndHorizontal();
        }