/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { var proxy = (PropertiesProxy)Values[0]; if (proxy.Asset == null || !proxy.Asset.IsLoaded) { layout.Label("Loading..."); return; } base.Initialize(layout); }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); if (Values.HasDifferentTypes == false) { // Add 'Bake' button layout.Space(10); var button = layout.Button("Bake"); button.Button.Clicked += BakeButtonClicked; } }
public virtual void OnNotAvailableLayout(LayoutElementsContainer layout) { layout.Label("Missing platform data tools for the target platform.", TextAlignment.Center); if (FlaxEditor.Editor.IsDevInstance()) { layout.Label("Build engine for this platform.", TextAlignment.Center); } else { layout.Label("Use Flax Launcher and download the required package.", TextAlignment.Center); } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { if (HasDifferentTypes) { // No support for different enum types } else { element = layout.Enum(Values[0].GetType()); element.ValueChanged += OnValueChanged; } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); // Reset options button layout.Space(30); var panel = layout.Space(30); var resetButton = new Button(4, 4, 100); resetButton.Text = "Reset"; resetButton.Parent = panel.ContainerControl; resetButton.Clicked += OnResetButtonClicked; }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { _labels.Clear(); base.Initialize(layout); // Add info box if (IsSingleObject && Values[0] is RigidBody && Editor.IsPlayMode) { _infoLabel = layout.Label(string.Empty).Label; _infoLabel.AutoHeight = true; } }
/// <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); }
private FloatValueElement CreateFloatEditor(LayoutElementsContainer layout, LimitAttribute limit, Color borderColor) { var element = layout.FloatValue(); element.SetLimits(limit); element.FloatValue.ValueChanged += OnValueChanged; var back = FlaxEngine.GUI.Style.Current.TextBoxBackground; var grayOutFactor = 0.6f; element.FloatValue.BorderColor = Color.Lerp(borderColor, back, grayOutFactor); element.FloatValue.BorderSelectedColor = borderColor; return(element); }
private bool OnGroupPanelCanPaste(LayoutElementsContainer layout) { if (layout.Editors.Count == 1) { return(layout.Editors[0].CanPaste); } if (layout.Editors.Count != 0) { var sb = Clipboard.Text; if (!string.IsNullOrEmpty(sb)) { try { var data = JsonSerializer.Deserialize <string[]>(sb); if (data == null || data.Length != layout.Editors.Count) { return(false); } for (var i = 0; i < layout.Editors.Count; i++) { Clipboard.Text = data[i]; if (!layout.Editors[i].CanPaste) { return(false); } } return(true); } catch { return(false); } finally { Clipboard.Text = sb; } } return(false); } if (layout.Children.Any(x => x is LayoutElementsContainer)) { foreach (var child in layout.Children) { if (child is LayoutElementsContainer childContainer) { return(OnGroupPanelCanPaste(childContainer)); } } } return(false); }
/// <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 sprites = (SpriteEntry[])Values[0]; if (sprites != null) { var elementType = typeof(SpriteEntry); for (int i = 0; i < sprites.Length; i++) { var group = layout.Group(sprites[i].Name); group.Object(new ListValueContainer(elementType, i, Values)); } } }
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 /> public override void Initialize(LayoutElementsContainer layout) { _label = layout.ClickableLabel(GetName(Culture)).CustomControl; _label.RightClick += ShowPicker; var button = new Button { Width = 16.0f, Text = "...", Parent = _label, }; button.SetAnchorPreset(AnchorPresets.MiddleRight, false, true); button.Clicked += ShowPicker; }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); if (Values.HasDifferentTypes == false) { layout.Space(10); var grid = layout.CustomContainer <UniformGridPanel>(); grid.CustomControl.SlotsHorizontally = 2; grid.CustomControl.SlotsVertically = 1; grid.Button("Set Linear Tangents").Button.Clicked += OnSetTangentsLinear; grid.Button("Set Smooth Tangents").Button.Clicked += OnSetTangentsSmooth; } }
/// <summary> /// Spawns the property for the given item. /// </summary> /// <param name="itemLayout">The item layout.</param> /// <param name="itemValues">The item values.</param> /// <param name="item">The item.</param> protected virtual void SpawnProperty(LayoutElementsContainer itemLayout, ValueContainer itemValues, ItemInfo item) { int labelIndex = 0; if ((item.IsReadOnly || item.VisibleIf != null) && itemLayout.Children.Count > 0 && itemLayout.Children[itemLayout.Children.Count - 1] is PropertiesListElement propertiesListElement) { labelIndex = propertiesListElement.Labels.Count; } itemLayout.Property(item.DisplayName, itemValues, item.OverrideEditor, item.TooltipText); if (item.IsReadOnly && itemLayout.Children.Count > 0) { PropertiesListElement list = null; int firstChildControlIndex = 0; bool disableSingle = true; var control = itemLayout.Children[itemLayout.Children.Count - 1]; if (control is GroupElement group && group.Children.Count > 0) { list = group.Children[0] as PropertiesListElement; disableSingle = false; // Disable all nested editors } else if (control is PropertiesListElement list1) { list = list1; firstChildControlIndex = list.Labels[labelIndex].FirstChildControlIndex; } if (list != null) { // Disable controls added to the editor var count = list.Properties.Children.Count; for (int j = firstChildControlIndex; j < count; j++) { var child = list.Properties.Children[j]; if (disableSingle && child is PropertyNameLabel) { break; } if (child != null) { child.Enabled = false; } } } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); var ragdoll = Values.Count == 1 ? Values[0] as Ragdoll : null; if (ragdoll == null) { return; } var editorGroup = layout.Group("Ragdoll Editor"); editorGroup.Panel.Open(false); // Info var text = $"Total mass: {Utils.RoundTo1DecimalPlace(ragdoll.TotalMass)}kg"; var label = editorGroup.Label(text); label.Label.AutoHeight = true; if (ragdoll.Parent is AnimatedModel animatedModel && animatedModel.SkinnedModel) { // Builder var grid = editorGroup.CustomContainer <UniformGridPanel>(); var gridControl = grid.CustomControl; gridControl.ClipChildren = false; gridControl.Height = Button.DefaultHeight; gridControl.SlotsHorizontally = 3; gridControl.SlotsVertically = 1; grid.Button("Rebuild").Button.ButtonClicked += OnRebuild; grid.Button("Rebuild/Add bone").Button.ButtonClicked += OnRebuildBone; grid.Button("Remove bone").Button.ButtonClicked += OnRemoveBone; } if (Presenter.Owner is Windows.PropertiesWindow || Presenter.Owner is Windows.Assets.PrefabWindow) { // Selection var grid = editorGroup.CustomContainer <UniformGridPanel>(); var gridControl = grid.CustomControl; gridControl.ClipChildren = false; gridControl.Height = Button.DefaultHeight; gridControl.SlotsHorizontally = 3; gridControl.SlotsVertically = 1; grid.Button("Select all joints").Button.Clicked += OnSelectAllJoints; grid.Button("Select all colliders").Button.Clicked += OnSelectAllColliders; grid.Button("Select all bodies").Button.Clicked += OnSelectAllBodies; } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); // Override colors var back = FlaxEngine.GUI.Style.Current.TextBoxBackground; var grayOutFactor = 0.6f; XElement.FloatValue.BorderColor = Color.Lerp(AxisColorX, back, grayOutFactor); XElement.FloatValue.BorderSelectedColor = AxisColorX; YElement.FloatValue.BorderColor = Color.Lerp(AxisColorY, back, grayOutFactor); YElement.FloatValue.BorderSelectedColor = AxisColorY; ZElement.FloatValue.BorderColor = Color.Lerp(AxisColorZ, back, grayOutFactor); ZElement.FloatValue.BorderSelectedColor = AxisColorZ; }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); var instance = (AnimEvent)Values[0]; if (instance == null) { return; } var scriptType = TypeUtils.GetObjectType(instance); var editor = CustomEditorsUtil.CreateEditor(scriptType, false); layout.Object(Values, editor); }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { _element = layout.ComboBox(); _element.ComboBox.SelectedIndexChanged += OnSelectedIndexChanged; _element.ComboBox.AddItem("None"); var groups = GameSettings.Load <StreamingSettings>(); if (groups?.TextureGroups != null) { for (int i = 0; i < groups.TextureGroups.Length; i++) { _element.ComboBox.AddItem(groups.TextureGroups[i].Name); } } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { bool isMultiLine = false; var attributes = Values.GetAttributes(); var multiLine = attributes?.FirstOrDefault(x => x is MultilineTextAttribute); if (multiLine != null) { isMultiLine = true; } _element = layout.TextBox(isMultiLine); _element.TextBox.EditEnd += () => SetValue(_element.Text); }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { // Atlas var atlasField = typeof(Sprite).GetField("Atlas"); var atlasValues = new ValueContainer(atlasField, Values); layout.Property("Atlas", atlasValues, null, "The target atlas texture used as a sprite image source."); _atlasValues = atlasValues; // Sprite var spriteIndexField = typeof(Sprite).GetField("Index"); _indexValues = new ValueContainer(spriteIndexField, Values); var spriteLabel = layout.AddPropertyItem("Sprite", "The selected sprite from the atlas."); // Check state if (atlasValues.HasDifferentValues) { spriteLabel.Label("Different values"); return; } var value = (SpriteAtlas)atlasValues[0]; if (value == null) { spriteLabel.Label("Pick atlas first"); return; } // TODO: don't stall use Refresh to rebuild UI when sprite atlas gets loaded if (value.WaitForLoaded()) { return; } // List all sprites from the atlas asset var spritesCount = value.SpritesCount; var spritePicker = spriteLabel.ComboBox(); spritePicker.ComboBox.Items.Capacity = spritesCount; for (int i = 0; i < spritesCount; i++) { spritePicker.ComboBox.AddItem(value.GetSprite(i).Name); } spritePicker.ComboBox.SupportMultiSelect = false; spritePicker.ComboBox.SelectedIndexChanged += OnSelectedIndexChanged; _spritePicker = spritePicker.ComboBox; }
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; case PlatformType.PS4: name = "PlayStation 4"; 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) { var editors = Editor.Instance.CodeEditing.Editors; var options = new string[editors.Count + 1]; options[0] = "None"; for (int i = 0; i < editors.Count; i++) { options[i + 1] = editors[i].Name; } _combobox = layout.ComboBox(); _combobox.ComboBox.SetItems(options); _combobox.ComboBox.SelectedItem = (string)Values[0]; _combobox.ComboBox.SelectedIndexChanged += OnComboBoxSelectedIndexChanged; }
public override void Initialize(LayoutElementsContainer layout) { var sprites = (SpriteEntry[])Values[0]; if (sprites != null) { var elementType = new ScriptType(typeof(SpriteEntry)); for (int i = 0; i < sprites.Length; i++) { var group = layout.Group(sprites[i].Name); group.Panel.Tag = i; group.Panel.MouseButtonRightClicked += OnGroupPanelMouseButtonRightClicked; group.Object(new ListValueContainer(elementType, i, Values)); } } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { float trackBallSize = 80.0f; float margin = 4.0f; // Panel var masterPanel = layout.CustomContainer <GridPanel>(); var masterPanelControl = masterPanel.CustomControl; masterPanelControl.ClipChildren = false; masterPanelControl.SlotPadding = new Margin(0, 0, margin, margin); masterPanelControl.Height = trackBallSize + margin + margin; masterPanelControl.ColumnFill = new[] { -trackBallSize, 1.0f }; masterPanelControl.RowFill = new[] { 1.0f }; // Trackball _trackball = masterPanel.Custom <ColorSelector>(); _trackball.CustomControl.ColorChanged += OnColorWheelChanged; _trackball.CustomControl.SlidingEnd += ClearToken; // Scale editor { var grid = masterPanel.CustomContainer <UniformGridPanel>(); var gridControl = grid.CustomControl; gridControl.SlotPadding = new Margin(4, 2, 2, 2); gridControl.ClipChildren = false; gridControl.SlotsHorizontally = 1; gridControl.SlotsVertically = 4; LimitAttribute limit = null; var attributes = Values.GetAttributes(); if (attributes != null) { limit = (LimitAttribute)attributes.FirstOrDefault(x => x is LimitAttribute); } _xElement = CreateFloatEditor(grid, limit, Color.Red); _yElement = CreateFloatEditor(grid, limit, Color.Green); _zElement = CreateFloatEditor(grid, limit, Color.Blue); _wElement = CreateFloatEditor(grid, limit, Color.White); } }
/// <inheritdoc /> internal override void Initialize(CustomEditorPresenter presenter, LayoutElementsContainer layout, ValueContainer values) { base.Initialize(presenter, layout, values); if (_element != null) { // Define the rule for the types that can be used to create a json data asset _element.CustomControl.CheckValid += type => type.Type != null && type.IsClass && type.Type.IsVisible && !type.IsAbstract && !type.IsGenericType && type.Type.GetConstructor(Type.EmptyTypes) != null && !typeof(FlaxEngine.Object).IsAssignableFrom(type.Type); } }
private void OnGroupPanelPaste(LayoutElementsContainer layout) { if (layout.Editors.Count == 1) { layout.Editors[0].Paste(); } else if (layout.Editors.Count != 0) { var sb = Clipboard.Text; if (!string.IsNullOrEmpty(sb)) { try { var data = JsonSerializer.Deserialize <string[]>(sb); if (data == null || data.Length != layout.Editors.Count) { return; } for (var i = 0; i < layout.Editors.Count; i++) { Clipboard.Text = data[i]; layout.Editors[i].Paste(); } } catch { } finally { Clipboard.Text = sb; } } } else if (layout.Children.Any(x => x is LayoutElementsContainer)) { foreach (var child in layout.Children) { if (child is LayoutElementsContainer childContainer) { OnGroupPanelPaste(childContainer); break; } } } }
/// <inheritdoc /> protected override void SpawnProperty(LayoutElementsContainer itemLayout, ValueContainer itemValues, ItemInfo item) { var order = item.Order.Order; if (order != FrictionCombineModeOrder && order != RestitutionCombineModeOrder) { base.SpawnProperty(itemLayout, itemValues, item); return; } // Add labels with a check box var label = new CheckablePropertyNameLabel(item.DisplayName); label.CheckBox.Tag = order; label.CheckChanged += CheckBoxOnCheckChanged; _labels.Add(label); itemLayout.Property(label, itemValues, item.OverrideEditor, item.TooltipText); }
/// <inheritdoc /> protected override void SpawnProperty(LayoutElementsContainer itemLayout, ValueContainer itemValues, ItemInfo item) { var setting = item.Info.GetCustomAttribute <PostProcessSettingAttribute>(); if (setting == null) { base.SpawnProperty(itemLayout, itemValues, item); return; } // Add labels with a check box var label = new CheckablePropertyNameLabel(item.DisplayName); label.CheckBox.Tag = setting.Bit; label.CheckChanged += CheckBoxOnCheckChanged; _labels.Add(label); itemLayout.Property(label, itemValues, item.OverrideEditor, item.TooltipText); }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { element = layout.ComboBox(); element.ComboBox.SelectedIndexChanged += OnSelectedIndexChanged; // Set node names if (ParentEditor != null && ParentEditor.Values.Count == 1 && ParentEditor.Values[0] is BoneSocket boneSocket && boneSocket.Parent is AnimatedModel animatedModel && animatedModel.SkinnedModel && !animatedModel.SkinnedModel.WaitForLoaded()) { var nodes = animatedModel.SkinnedModel.Nodes; for (int nodeIndex = 0; nodeIndex < nodes.Length; nodeIndex++) { element.ComboBox.AddItem(nodes[nodeIndex].Name); } } }