private void UpdateCombo() { if (_isUpdating) { return; } _isUpdating = true; // Cache combo box if (_combobox == null) { _combobox = (ComboBoxElement)_children[0]; _combobox.SelectedIndexChanged += OnSelectedChanged; } // Update items Type type = null; var toSelect = (string)Values[1]; var asset = FlaxEngine.Content.Load <GameplayGlobals>((Guid)Values[0]); _combobox.ClearItems(); if (asset) { var values = asset.DefaultValues; var tooltips = new string[values.Count]; var i = 0; foreach (var e in values) { _combobox.AddItem(e.Key); tooltips[i++] = "Type: " + CustomEditorsUtil.GetTypeNameUI(e.Value.GetType()) + ", default value: " + e.Value; if (toSelect == e.Key) { type = e.Value.GetType(); } } _combobox.Tooltips = tooltips; } // Preserve selected item _combobox.SelectedItem = toSelect; // Update output value type var box = GetBox(0); if (type == null) { box.Enabled = false; } else { box.Enabled = true; box.CurrentType = VisjectSurface.GetValueTypeConnectionType(type); } _isUpdating = false; }
public override void Initialize(LayoutElementsContainer layout) { _proxy = (PropertiesProxy)Values[0]; if (_proxy?.DefaultValues == null) { layout.Label("Loading...", TextAlignment.Center); return; } var isPlayModeActive = _proxy.Window.Editor.StateMachine.IsPlayMode; if (isPlayModeActive) { layout.Label("Play mode is active. Editing runtime values.", TextAlignment.Center); layout.Space(10); foreach (var e in _proxy.DefaultValues) { var name = e.Key; var value = _proxy.Asset.GetValue(name); var valueContainer = new VariableValueContainer(_proxy, name, value, false); var propertyLabel = new PropertyNameLabel(name) { Tag = name, }; string tooltip = null; if (_proxy.DefaultValues.TryGetValue(name, out var defaultValue)) { tooltip = "Default value: " + defaultValue; } layout.Object(propertyLabel, valueContainer, null, tooltip); } } else { foreach (var e in _proxy.DefaultValues) { var name = e.Key; var value = e.Value; var valueContainer = new VariableValueContainer(_proxy, name, value, true); var propertyLabel = new ClickablePropertyNameLabel(name) { Tag = name, }; propertyLabel.MouseLeftDoubleClick += (label, location) => StartParameterRenaming(name, label); propertyLabel.SetupContextMenu += OnPropertyLabelSetupContextMenu; layout.Object(propertyLabel, valueContainer, null, "Type: " + CustomEditorsUtil.GetTypeNameUI(value.GetType())); } // TODO: improve the UI layout.Space(40); var addParamType = layout.ComboBox().ComboBox; addParamType.Items = AllowedTypes.Select(CustomEditorsUtil.GetTypeNameUI).ToList(); addParamType.SelectedIndex = 0; _addParamType = addParamType; var addParamButton = layout.Button("Add").Button; addParamButton.Clicked += OnAddParamButtonClicked; } }