Exemplo n.º 1
0
    // Returns current selected option
    private string UpdateTextDictionary <T>(Dictionary <string, T> dictionary, TextOptionsHandle handle)
        where T : new()
    {
        handle.name = EditorGUILayout.TextField(handle.name);

        if (dictionary.Count != 0)
        {
            var options = dictionary.Keys.ToArray();
            handle.index = EditorGUILayout.Popup(handle.index, options);
            return(options[handle.index]);
        }
        else
        {
            if (GUILayout.Button("Start"))
            {
                dictionary.Add(handle.name, new T());
            }
            return("");
        }
    }
Exemplo n.º 2
0
    private void AddDeleteWidget <T>(Dictionary <string, T> dictionary, TextOptionsHandle handle)
        where T : new()
    {
        var options = dictionary.Keys.ToArray();

        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("Add"))
        {
            if (!dictionary.ContainsKey(handle.name))
            {
                dictionary.Add(handle.name, new T());
            }
        }

        if (GUILayout.Button("Delete"))
        {
            dictionary.Remove(options[handle.index]);
        }

        EditorGUILayout.EndHorizontal();
    }