Exemplo n.º 1
0
        protected override void InitializeGUI(ElementGUI <T> gui)
        {
            base.InitializeGUI(gui);
            ValueGUI <T> valueGUI = (ValueGUI <T>)gui;

            valueGUI.MinValue   = this.MinValue;
            valueGUI.MaxValue   = this.MaxValue;
            valueGUI.Decimals   = this.Decimals;
            valueGUI.FieldWidth = this.FieldWidth;
            valueGUI.WithSlider = this.WithSlider;
        }
Exemplo n.º 2
0
            private static void DoGUILayout <TKey, TValue>(SDictionary <TKey, TValue> dict, ValueGUI <TValue> valueGUI, bool oneLine, bool showRemove)
            {
                EditorGUI.indentLevel++;
                TKey toDelete = default;
                bool delete   = false;

                TKey[] keys = new TKey[dict.Count];
                dict.Keys.CopyTo(keys, 0);
                System.Array.Sort(keys);
                foreach (var key in keys)
                {
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel(key.ToString());
                    GUILayout.Space(1);
                    if (oneLine)
                    {
                        dict[key] = valueGUI(dict[key]);
                    }
                    if (showRemove)
                    {
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("-", GUILayout.Width(45)))
                        {
                            toDelete = key;
                            delete   = true;
                        }
                    }
                    GUILayout.EndHorizontal();
                    if (!oneLine)
                    {
                        dict[key] = valueGUI(dict[key]);
                    }
                }
                if (delete)
                {
                    dict.Remove(toDelete);
                }
                EditorGUI.indentLevel--;
                EditorUtils.Separator();
            }
Exemplo n.º 3
0
 public static void DoGUILayout <TKey, TValue>(this SDictionary <TKey, TValue> dict, ValueGUI <TValue> valueGUI, AddGUI addGUI, string title, bool oneLine = false, bool showRemove = true)
 {
     GUILayout.BeginHorizontal();
     EditorGUILayout.LabelField(title + ": " + dict.Count, EditorUtils.Bold, GUILayout.MaxWidth(120));
     GUILayout.Space(-20);
     //GUILayout.FlexibleSpace();
     addGUI();
     GUILayout.EndHorizontal();
     EditorUtils.Separator();
     if (dict.Count > 0)
     {
         DoGUILayout(dict, valueGUI, oneLine, showRemove);
     }
 }