Пример #1
0
        private void OnOptionGUI(string name)
        {
            EnsureOptions();
            string[] values;
            if (!_options.TryGetValue(name, out values) || values.Length == 0)
            {
                return;
            }

            var option = BuilderPreferences.GetLastOption(name);

            int selected = -1;

            if (!string.IsNullOrEmpty(option))
            {
                selected = Array.IndexOf(values, option);

                if (selected <= 0 && !string.IsNullOrEmpty(option))
                {
                    BuilderPreferences.SetLastOption(name, EditorGUILayout.TextField(name, option));
                    return;
                }
            }

            selected = EditorGUILayout.Popup(name, selected, values);
            BuilderPreferences.SetLastOption(name, selected > 0 ? values[selected] : null);
        }
Пример #2
0
        private Dictionary <string, string> GetCurrentOptions()
        {
            Dictionary <string, string> result = null;

            EnsureOptions();
            foreach (var p in _options)
            {
                var val = BuilderPreferences.GetLastOption(p.Key);
                if (val == null || Array.IndexOf(p.Value, val) < 0)
                {
                    continue;
                }
                if (result == null)
                {
                    result = new Dictionary <string, string>(_options.Count);
                }
                result[p.Key] = val;
            }
            return(result);
        }