/// <summary> /// Initializes a new instance of the <see cref="ItemInfo"/> class. /// </summary> /// <param name="info">The reflection information.</param> /// <param name="attributes">The attributes.</param> public ItemInfo(MemberInfo info, object[] attributes) { Info = info; Order = (EditorOrderAttribute)attributes.FirstOrDefault(x => x is EditorOrderAttribute); Display = (EditorDisplayAttribute)attributes.FirstOrDefault(x => x is EditorDisplayAttribute); Tooltip = (TooltipAttribute)attributes.FirstOrDefault(x => x is TooltipAttribute); CustomEditor = (CustomEditorAttribute)attributes.FirstOrDefault(x => x is CustomEditorAttribute); CustomEditorAlias = (CustomEditorAliasAttribute)attributes.FirstOrDefault(x => x is CustomEditorAliasAttribute); Space = (SpaceAttribute)attributes.FirstOrDefault(x => x is SpaceAttribute); Header = (HeaderAttribute)attributes.FirstOrDefault(x => x is HeaderAttribute); VisibleIf = (VisibleIfAttribute)attributes.FirstOrDefault(x => x is VisibleIfAttribute); IsReadOnly = attributes.FirstOrDefault(x => x is ReadOnlyAttribute) != null; ExpandGroups = attributes.FirstOrDefault(x => x is ExpandGroupsAttribute) != null; if (!IsReadOnly && info is FieldInfo fieldInfo && fieldInfo.IsInitOnly) { // Field declared with `readonly` keyword IsReadOnly = true; } if (!IsReadOnly && info is PropertyInfo propertyInfo && !propertyInfo.CanWrite) { // Property without a setter IsReadOnly = true; } if (Display?.Name != null) { // Use name provided by the attribute DisplayName = Display.Name; } else { // Use filtered member name DisplayName = CustomEditorsUtil.GetPropertyNameUI(info.Name); } }
/// <summary> /// Initializes a new instance of the <see cref="ItemInfo"/> class. /// </summary> /// <param name="info">The reflection information.</param> /// <param name="attributes">The attributes.</param> public ItemInfo(MemberInfo info, object[] attributes) { Info = info; Order = (EditorOrderAttribute)attributes.FirstOrDefault(x => x is EditorOrderAttribute); Display = (EditorDisplayAttribute)attributes.FirstOrDefault(x => x is EditorDisplayAttribute); Tooltip = (TooltipAttribute)attributes.FirstOrDefault(x => x is TooltipAttribute); CustomEditor = (CustomEditorAttribute)attributes.FirstOrDefault(x => x is CustomEditorAttribute); CustomEditorAlias = (CustomEditorAliasAttribute)attributes.FirstOrDefault(x => x is CustomEditorAliasAttribute); Space = (SpaceAttribute)attributes.FirstOrDefault(x => x is SpaceAttribute); Header = (HeaderAttribute)attributes.FirstOrDefault(x => x is HeaderAttribute); VisibleIf = (VisibleIfAttribute)attributes.FirstOrDefault(x => x is VisibleIfAttribute); IsReadOnly = attributes.FirstOrDefault(x => x is ReadOnlyAttribute) != null; ExpandGroups = attributes.FirstOrDefault(x => x is ExpandGroupsAttribute) != null; if (Display?.Name != null) { // Use name provided by the attribute DisplayName = Display.Name; } else { // Use filtered member name DisplayName = CustomEditorsUtil.GetPropertyNameUI(info.Name); } }
public override void Initialize(LayoutElementsContainer layout) { var proxy = (BuildTabProxy)Values[0]; _platform = proxy.Selector.Selected; var platformObj = proxy.PerPlatformOptions[_platform]; if (!platformObj.IsSupported) { layout.Label("This platform is not supported on this system.", TextAlignment.Center); } else if (platformObj.IsAvailable) { string name; switch (_platform) { case PlatformType.Windows: name = "Windows"; break; case PlatformType.XboxOne: name = "Xbox One"; break; case PlatformType.UWP: name = "Windows Store"; break; case PlatformType.Linux: name = "Linux"; break; case PlatformType.PS4: name = "PlayStation 4"; break; case PlatformType.XboxScarlett: name = "Xbox Scarlett"; break; case PlatformType.Android: name = "Android"; break; default: name = CustomEditorsUtil.GetPropertyNameUI(_platform.ToString()); break; } var group = layout.Group(name); group.Object(new ReadOnlyValueContainer(platformObj)); _buildButton = layout.Button("Build").Button; _buildButton.Clicked += OnBuildClicked; } else { platformObj.OnNotAvailableLayout(layout); } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { _scripts.Clear(); // Area for drag&drop scripts var dragArea = layout.Custom <DragAreaControl>(); dragArea.CustomControl.ScriptsEditor = this; // No support to show scripts for more than one actor selected if (Values.Count != 1) { return; } // Scripts var scripts = (Script[])Values[0]; _scripts.AddRange(scripts); var elementType = typeof(Script); for (int i = 0; i < scripts.Length; i++) { var script = scripts[i]; if (script == null) { layout.Group("Missing script"); continue; } var values = new ListValueContainer(elementType, i, Values); var type = script.GetType(); var editor = CustomEditorsUtil.CreateEditor(type, false); // Create group var title = CustomEditorsUtil.GetPropertyNameUI(type.Name); var group = layout.Group(title); group.Panel.Open(false); // Add settings button to the group const float settingsButtonSize = 14; var settingsButton = new Image(group.Panel.Width - settingsButtonSize, 0, settingsButtonSize, settingsButtonSize) { CanFocus = true, AnchorStyle = AnchorStyle.UpperRight, IsScrollable = false, Color = new Color(0.7f), Margin = new Margin(1), ImageSource = new SpriteImageSource(FlaxEngine.GUI.Style.Current.Settings), Tag = script, Parent = group.Panel }; settingsButton.Clicked += SettingsButtonOnClicked; group.Object(values, editor); } base.Initialize(layout); }
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; }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); var instance = (AnimEvent)Values[0]; var scriptType = TypeUtils.GetObjectType(instance); var editor = CustomEditorsUtil.CreateEditor(scriptType, false); layout.Object(Values, editor); }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { var options = (IList <Type>)Presenter.Panel.Tag; _options = new OptionType[options.Count]; for (int i = 0; i < options.Count; i++) { var type = options[i]; _options[i] = new OptionType(CustomEditorsUtil.GetPropertyNameUI(type.Name), type, Creator); } base.Initialize(layout); }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { // Get the target options _options = Options; if (_options == null) { throw new ArgumentNullException(); } int selectedIndex = -1; bool hasDifferentTypes = Values.HasDifferentTypes; var type = Type; _type = type; // Type var typeEditor = layout.ComboBox("Type", "Type of the object value. Use it to change the object."); for (int i = 0; i < _options.Length; i++) { typeEditor.ComboBox.AddItem(_options[i].Name); selectedIndex = _options[i].Type == type ? i : selectedIndex; } typeEditor.ComboBox.SupportMultiSelect = false; typeEditor.ComboBox.SelectedIndex = hasDifferentTypes ? -1 : selectedIndex; typeEditor.ComboBox.SelectedIndexChanged += OnSelectedIndexChanged; // Editing different types is not supported if (Values.HasDifferentTypes) { var property = layout.AddPropertyItem("Value"); property.Label("Different Values"); return; } // Nothing to edit if (Values.HasNull) { var property = layout.AddPropertyItem("Value"); property.Label("<null>"); return; } // Value var values = new CustomValueContainer(type, (instance, index) => instance, (instance, index, value) => { }); values.AddRange(Values); var editor = CustomEditorsUtil.CreateEditor(type); layout.Property("Value", values, editor); }
public override void Initialize(LayoutElementsContainer layout) { var proxy = (BuildTabProxy)Values[0]; _platform = proxy.Selector.Selected; var platformObj = proxy.PerPlatformOptions[_platform]; var group = layout.Group(CustomEditorsUtil.GetPropertyNameUI(_platform.ToString())); group.Object(new ReadOnlyValueContainer(platformObj)); _buildButton = layout.Button("Build").Button; _buildButton.Clicked += OnBuildClicked; }
/// <inheritdoc /> protected override void OnShowAddContextMenu(ContextMenu.ContextMenu menu) { base.OnShowAddContextMenu(menu); OnSelectActorContextMenu(menu); var actor = Actor; if (actor == null) { return; } var type = actor.GetType(); menu.AddSeparator(); // Properties and events if (AddProperties(this, menu, type) != 0) { menu.AddSeparator(); } if (AddEvents(this, menu, type) != 0) { menu.AddSeparator(); } // Child scripts var scripts = actor.Scripts; for (int i = 0; i < scripts.Length; i++) { var script = scripts[i]; // Skip invalid or hidden scripts if (script == null || script.GetType().GetCustomAttributes(true).Any(x => x is HideInEditorAttribute)) { continue; } // Prevent from adding the same track twice if (SubTracks.Any(x => x is IObjectTrack y && y.Object == script)) { continue; } var name = CustomEditorsUtil.GetPropertyNameUI(script.GetType().Name); menu.AddButton(name, OnAddScriptTrack).Tag = script; } }
/// <summary> /// Initializes a new instance of the <see cref="ItemInfo"/> class. /// </summary> /// <param name="info">The reflection information.</param> /// <param name="attributes">The attributes.</param> public ItemInfo(ScriptMemberInfo info, object[] attributes) { Info = info; Order = (EditorOrderAttribute)attributes.FirstOrDefault(x => x is EditorOrderAttribute); Display = (EditorDisplayAttribute)attributes.FirstOrDefault(x => x is EditorDisplayAttribute); Tooltip = (TooltipAttribute)attributes.FirstOrDefault(x => x is TooltipAttribute); CustomEditor = (CustomEditorAttribute)attributes.FirstOrDefault(x => x is CustomEditorAttribute); CustomEditorAlias = (CustomEditorAliasAttribute)attributes.FirstOrDefault(x => x is CustomEditorAliasAttribute); Space = (SpaceAttribute)attributes.FirstOrDefault(x => x is SpaceAttribute); Header = (HeaderAttribute)attributes.FirstOrDefault(x => x is HeaderAttribute); VisibleIf = (VisibleIfAttribute)attributes.FirstOrDefault(x => x is VisibleIfAttribute); IsReadOnly = attributes.FirstOrDefault(x => x is ReadOnlyAttribute) != null; ExpandGroups = attributes.FirstOrDefault(x => x is ExpandGroupsAttribute) != null; IsReadOnly |= !info.HasSet; DisplayName = Display?.Name ?? CustomEditorsUtil.GetPropertyNameUI(info.Name); }
public override void Initialize(LayoutElementsContainer layout) { var proxy = (BuildTabProxy)Values[0]; _platform = proxy.Selector.Selected; var platformObj = proxy.PerPlatformOptions[_platform]; if (platformObj.IsAvailable) { string name; switch (_platform) { case PlatformType.Windows: name = "Windows"; break; case PlatformType.XboxOne: name = "Xbox One"; break; case PlatformType.WindowsStore: name = "Windows Store"; break; case PlatformType.Linux: name = "Linux"; break; default: name = CustomEditorsUtil.GetPropertyNameUI(_platform.ToString()); break; } var group = layout.Group(name); group.Object(new ReadOnlyValueContainer(platformObj)); _buildButton = layout.Button("Build").Button; _buildButton.Clicked += OnBuildClicked; } else { platformObj.OnNotAvailableLayout(layout); } }
/// <summary> /// Initializes a new instance of the <see cref="ItemInfo"/> class. /// </summary> /// <param name="info">The reflection information.</param> /// <param name="attributes">The attributes.</param> public ItemInfo(ScriptMemberInfo info, object[] attributes) { Info = info; Order = (EditorOrderAttribute)attributes.FirstOrDefault(x => x is EditorOrderAttribute); Display = (EditorDisplayAttribute)attributes.FirstOrDefault(x => x is EditorDisplayAttribute); CustomEditor = (CustomEditorAttribute)attributes.FirstOrDefault(x => x is CustomEditorAttribute); CustomEditorAlias = (CustomEditorAliasAttribute)attributes.FirstOrDefault(x => x is CustomEditorAliasAttribute); Space = (SpaceAttribute)attributes.FirstOrDefault(x => x is SpaceAttribute); Header = (HeaderAttribute)attributes.FirstOrDefault(x => x is HeaderAttribute); VisibleIf = (VisibleIfAttribute)attributes.FirstOrDefault(x => x is VisibleIfAttribute); IsReadOnly = attributes.FirstOrDefault(x => x is ReadOnlyAttribute) != null; ExpandGroups = attributes.FirstOrDefault(x => x is ExpandGroupsAttribute) != null; IsReadOnly |= !info.HasSet; DisplayName = Display?.Name ?? CustomEditorsUtil.GetPropertyNameUI(info.Name); var editor = Editor.Instance; TooltipText = editor.CodeDocs.GetTooltip(info, attributes); _membersOrder = editor.Options.Options.General.ScriptMembersOrder; }
private TreeNode CreateDiffNode(CustomEditor editor) { var node = new TreeNode(false) { Tag = editor }; // Removed Script if (editor is RemovedScriptDummy removed) { node.TextColor = Color.OrangeRed; node.Text = CustomEditorsUtil.GetPropertyNameUI(removed.PrefabObject.GetType().Name); } // Actor or Script else if (editor.Values[0] is ISceneObject sceneObject) { node.TextColor = sceneObject.HasPrefabLink ? FlaxEngine.GUI.Style.Current.ProgressNormal : FlaxEngine.GUI.Style.Current.BackgroundSelected; node.Text = CustomEditorsUtil.GetPropertyNameUI(sceneObject.GetType().Name); } // Array Item else if (editor.ParentEditor?.Values?.Type.IsArray ?? false) { node.Text = "Element " + editor.ParentEditor.ChildrenEditors.IndexOf(editor); } // Common type else if (editor.Values.Info != ScriptMemberInfo.Null) { node.Text = CustomEditorsUtil.GetPropertyNameUI(editor.Values.Info.Name); } // Custom type else if (editor.Values[0] != null) { node.Text = editor.Values[0].ToString(); } node.Expand(true); return(node); }
/// <summary> /// Creates new Combo Box element description for enum editing. /// </summary> /// <param name="x">The x location (in node area space).</param> /// <param name="y">The y location (in node area space).</param> /// <param name="width">The width of the element.</param> /// <param name="valueIndex">The index of the node variable linked as the input. Useful to make a physical connection between input box and default value for it.</param> /// <param name="enumType">The enum type to present all it's values. Important: first value should be 0 and so on.</param> /// <returns>The archetype.</returns> public static NodeElementArchetype ComboBox(float x, float y, int width, int valueIndex, Type enumType) { if (enumType == null || !enumType.IsEnum) { throw new ArgumentException(); } FieldInfo[] fields = enumType.GetFields(); List <string> values = new List <string>(fields.Length); for (int i = 0; i < fields.Length; i++) { var field = fields[i]; if (field.Name.Equals("value__")) { continue; } var name = CustomEditorsUtil.GetPropertyNameUI(field.Name); values.Add(name); } return(ComboBox(x, y, width, valueIndex, values.ToArray())); }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { // Get the target options _options = Options; if (_options == null) { throw new ArgumentNullException(); } int selectedIndex = -1; bool hasDifferentTypes = Values.HasDifferentTypes; var type = Type; _type = type; // Type var typeEditor = layout.ComboBox(TypeComboBoxName, "Type of the object value. Use it to change the object."); for (int i = 0; i < _options.Length; i++) { typeEditor.ComboBox.AddItem(_options[i].Name); selectedIndex = _options[i].Type == type.Type ? i : selectedIndex; } typeEditor.ComboBox.SupportMultiSelect = false; typeEditor.ComboBox.SelectedIndex = hasDifferentTypes ? -1 : selectedIndex; typeEditor.ComboBox.SelectedIndexChanged += OnSelectedIndexChanged; // Editing different types is not supported if (Values.HasDifferentTypes) { var property = layout.AddPropertyItem("Value"); property.Label("Different Values"); return; } // Nothing to edit if (Values.HasNull) { var property = layout.AddPropertyItem("Value"); property.Label("<null>"); return; } // Value var values = new CustomValueContainer(type, (instance, index) => instance, (instance, index, value) => { }); values.AddRange(Values); var editor = CustomEditorsUtil.CreateEditor(type); var style = editor.Style; if (style == DisplayStyle.InlineIntoParent) { layout.Object(values, editor); } else if (style == DisplayStyle.Group) { var group = layout.Group("Value", true); group.Panel.Open(false); group.Object(values, editor); // Remove empty group if (group.ContainerControl.ChildrenCount == 0) { layout.Children.Remove(group); group.Panel.Dispose(); } } else { layout.AddPropertyItem("Value").Object(values, editor); } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { _scripts.Clear(); // Area for drag&drop scripts var dragArea = layout.CustomContainer <DragAreaControl>(); dragArea.CustomControl.ScriptsEditor = this; // No support to show scripts for more than one actor selected // TODO: support showing scripts from objects that has the same scripts layout if (Values.Count != 1) { return; } // Scripts arrange bar var dragBar = layout.Custom <ScriptArrangeBar>(); dragBar.CustomControl.Init(0, this); // Scripts var scripts = (Script[])Values[0]; _scripts.AddRange(scripts); var elementType = typeof(Script); for (int i = 0; i < scripts.Length; i++) { var script = scripts[i]; if (script == null) { AddMissingScript(i, layout); continue; } var values = new ListValueContainer(elementType, i, Values); var type = script.GetType(); var editor = CustomEditorsUtil.CreateEditor(type, false); // Create group var title = CustomEditorsUtil.GetPropertyNameUI(type.Name); var group = layout.Group(title); group.Panel.Open(false); // Customize var typeAttributes = type.GetCustomAttributes(true); var tooltip = (TooltipAttribute)typeAttributes.FirstOrDefault(x => x is TooltipAttribute); if (tooltip != null) { group.Panel.TooltipText = tooltip.Text; } // Add toggle button to the group var scriptToggle = new CheckBox(2, 0, script.Enabled) { TooltipText = "If checked, script will be enabled", IsScrollable = false, Size = new Vector2(14, 14), BoxSize = 12.0f, Tag = script, Parent = group.Panel }; scriptToggle.StateChanged += ScriptToggleOnCheckChanged; // Add drag button to the group const float dragIconSize = 14; var scriptDrag = new ScriptDragIcon(this, script, scriptToggle.Right, 0.5f, dragIconSize) { TooltipText = "Script reference", CanFocus = true, IsScrollable = false, Color = new Color(0.7f), Margin = new Margin(1), ImageSource = new SpriteImageSource(Editor.Instance.UI.DragBar12), Tag = script, Parent = group.Panel }; // Add settings button to the group const float settingsButtonSize = 14; var settingsButton = new Image(group.Panel.Width - settingsButtonSize, 0, settingsButtonSize, settingsButtonSize) { TooltipText = "Settings", CanFocus = true, AnchorStyle = AnchorStyle.UpperRight, IsScrollable = false, Color = new Color(0.7f), Margin = new Margin(1), ImageSource = new SpriteImageSource(FlaxEngine.GUI.Style.Current.Settings), Tag = script, Parent = group.Panel }; settingsButton.Clicked += SettingsButtonOnClicked; group.Panel.HeaderTextMargin = new Margin(scriptDrag.Right, 15, 2, 2); group.Object(values, editor); // Scripts arrange bar dragBar = layout.Custom <ScriptArrangeBar>(); dragBar.CustomControl.Init(i + 1, this); } base.Initialize(layout); }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { // Area for drag&drop scripts var dragArea = layout.CustomContainer <DragAreaControl>(); dragArea.CustomControl.ScriptsEditor = this; // No support for showing scripts from multiple actors that have different set of scripts var scripts = (Script[])Values[0]; _scripts.Clear(); _scripts.AddRange(scripts); for (int i = 1; i < Values.Count; i++) { var e = (Script[])Values[i]; if (scripts.Length != e.Length) { return; } for (int j = 0; j < e.Length; j++) { var t1 = scripts[j]?.TypeName; var t2 = e[j]?.TypeName; if (t1 != t2) { return; } } } // Scripts arrange bar var dragBar = layout.Custom <ScriptArrangeBar>(); dragBar.CustomControl.Init(0, this); // Scripts var elementType = new ScriptType(typeof(Script)); _scriptToggles = new CheckBox[scripts.Length]; for (int i = 0; i < scripts.Length; i++) { var script = scripts[i]; if (script == null) { AddMissingScript(i, layout); continue; } var values = new ScriptsContainer(elementType, i, Values); var scriptType = TypeUtils.GetObjectType(script); var editor = CustomEditorsUtil.CreateEditor(scriptType, false); // Create group var title = Utilities.Utils.GetPropertyNameUI(scriptType.Name); var group = layout.Group(title, editor); if ((Presenter.Features & FeatureFlags.CacheExpandedGroups) != 0) { if (Editor.Instance.ProjectCache.IsCollapsedGroup(title)) { group.Panel.Close(false); } else { group.Panel.Open(false); } group.Panel.IsClosedChanged += panel => Editor.Instance.ProjectCache.SetCollapsedGroup(panel.HeaderText, panel.IsClosed); } else { group.Panel.Open(false); } // Customize group.Panel.TooltipText = Editor.Instance.CodeDocs.GetTooltip(scriptType); if (script.HasPrefabLink) { group.Panel.HeaderTextColor = FlaxEngine.GUI.Style.Current.ProgressNormal; } // Add toggle button to the group var scriptToggle = new CheckBox { TooltipText = "If checked, script will be enabled.", IsScrollable = false, Checked = script.Enabled, Parent = group.Panel, Size = new Float2(14, 14), Bounds = new Rectangle(2, 0, 14, 14), BoxSize = 12.0f, Tag = script, }; scriptToggle.StateChanged += OnScriptToggleCheckChanged; _scriptToggles[i] = scriptToggle; // Add drag button to the group const float dragIconSize = 14; var scriptDrag = new ScriptDragIcon(this, script) { TooltipText = "Script reference", AutoFocus = true, IsScrollable = false, Color = FlaxEngine.GUI.Style.Current.ForegroundGrey, Parent = group.Panel, Bounds = new Rectangle(scriptToggle.Right, 0.5f, dragIconSize, dragIconSize), Margin = new Margin(1), Brush = new SpriteBrush(Editor.Instance.Icons.DragBar12), Tag = script, }; // Add settings button to the group const float settingsButtonSize = 14; var settingsButton = new Image { TooltipText = "Settings", AutoFocus = true, AnchorPreset = AnchorPresets.TopRight, Parent = group.Panel, Bounds = new Rectangle(group.Panel.Width - settingsButtonSize, 0, settingsButtonSize, settingsButtonSize), IsScrollable = false, Color = FlaxEngine.GUI.Style.Current.ForegroundGrey, Margin = new Margin(1), Brush = new SpriteBrush(FlaxEngine.GUI.Style.Current.Settings), Tag = script, }; settingsButton.Clicked += OnSettingsButtonClicked; group.Panel.HeaderTextMargin = new Margin(scriptDrag.Right, 15, 2, 2); group.Object(values, editor); // Scripts arrange bar dragBar = layout.Custom <ScriptArrangeBar>(); dragBar.CustomControl.Init(i + 1, this); } base.Initialize(layout); }
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; } }