/// <summary> /// Initializes this editor. /// </summary> /// <param name="layout">The layout builder.</param> public override void Initialize(LayoutElementsContainer layout) { Style style = (Style)this.Values[0]; _element = layout.Custom <StyleValueEditor>(); _element.CustomControl.Value = style; _element.CustomControl.ValueChanged += OnValueChanged; }
/// <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); }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { if (!HasDifferentTypes) { _type = Values.Type != typeof(object) || Values[0] == null ? Values.Type : Values[0].GetType(); float height = 48; var attributes = Values.GetAttributes(); if (attributes != null) { var assetReference = (AssetReferenceAttribute)attributes.FirstOrDefault(x => x is AssetReferenceAttribute); if (assetReference != null) { if (assetReference.UseSmallPicker) { height = 32; } if (!string.IsNullOrEmpty(assetReference.TypeName)) { var customType = Utilities.Utils.GetType(assetReference.TypeName); if (customType != null) { _type = customType; } else { Debug.LogWarning(string.Format("Unknown asset type '{0}' to use for asset picker filter.", assetReference.TypeName)); } } } } _element = layout.Custom <AssetPicker>(); _element.CustomControl.AssetType = _type; _element.CustomControl.Height = height; _element.CustomControl.SelectedItemChanged += OnSelectedItemChanged; } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { element = layout.Custom <ColorValueBox>(); element.CustomControl.ValueChanged += OnValueChanged; }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { if (!HasDiffrentTypes) { // TODO: find better way to get content domain from the asset type (mayb util function?) var domain = ContentDomain.Other; type = Values.Type != typeof(object) || Values[0] == null ? Values.Type : Values[0].GetType(); if (type == typeof(Texture) || type == typeof(SpriteAtlas)) { domain = ContentDomain.Texture; } else if (type == typeof(CubeTexture)) { domain = ContentDomain.CubeTexture; } else if (type == typeof(Material) || type == typeof(MaterialInstance) || type == typeof(MaterialBase)) { domain = ContentDomain.Material; } else if (type == typeof(Model)) { domain = ContentDomain.Model; } //else if (type == typeof(PrefabAsset)) // domain = ContentDomain.Prefab; else if (type == typeof(Shader)) { domain = ContentDomain.Shader; } else if (type == typeof(FontAsset)) { domain = ContentDomain.Font; } else if (type == typeof(IESProfile)) { domain = ContentDomain.IESProfile; } else if (type == typeof(AudioClip)) { domain = ContentDomain.Audio; } //else if (type == typeof(SceneAsset)) // domain = ContentDomain.Scene; else if (type == typeof(JsonAsset)) { domain = JsonAsset.Domain; } typeName = null; float height = 48; if (Values.Info != null) { var attributes = Values.Info.GetCustomAttributes(true); var assetReference = (AssetReferenceAttribute)attributes.FirstOrDefault(x => x is AssetReferenceAttribute); if (assetReference != null) { typeName = assetReference.TypeName; if (assetReference.UseSmallPicker) { height = 24; } if (typeName == SceneItem.SceneAssetTypename) { domain = ContentDomain.Scene; } } } element = layout.Custom <AssetPicker>(); element.CustomControl.Domain = domain; element.CustomControl.Height = height; element.CustomControl.SelectedItemChanged += OnSelectedItemChanged; element.CustomControl.ValidateValue += ValidateValue; } }
/// <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); }