void Start () { loader = GameSettingsComponent.loader; quick_import.options.Clear(); //Automatically set the dropdown to the default file if one is present. default_option.CombineLatest( quick_import_options.ObserveCountChanged(), (index, count)=>{ return Math.Min(index,count); } ).Subscribe(value=>{ quick_import.value = value; if (value < quick_import_options.Count) quick_import_options[value].rx_display_text.Subscribe(text=>{ if (quick_import != null && quick_import.value == value) quick_import.captionText.text = text; }); }); //Keep the box synced with the loader when possible. loader_sub = loader.rx_filename.Subscribe((file)=>{ foreach (QuickImportOption opt in quick_import_options){ if (quick_import != null && opt.option_name == file){ quick_import.captionText.text = opt.rx_display_text.Value; } } }); select_sub = quick_import .SelectFromCollection(quick_import_options, (opt, index)=>{ if (default_option.Value == 0 && string.Equals(opt.option_name, "default", StringComparison.CurrentCultureIgnoreCase)){ //If this option calls itself "default," set our default index to it. default_option.Value = index; } return opt.dropdown_option; }).Subscribe(option=>{ data_component.current_rules = loader.load(option.option_name); }); quick_import_options.SetRange(loader.available_files().Select(name=>new QuickImportOption(name))); }