Merge branch 'FlaxEngine:master' into color-picker

This commit is contained in:
Menotdan
2023-05-17 21:12:37 -04:00
committed by GitHub
11 changed files with 168 additions and 54 deletions

View File

@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using FlaxEditor.CustomEditors.Dedicated;
using FlaxEditor.CustomEditors.Editors;
using FlaxEditor.Scripting;
using FlaxEngine;
@@ -107,7 +108,7 @@ namespace FlaxEditor.CustomEditors
// Select default editor (based on type)
if (targetType.IsEnum)
return new EnumEditor();
if (targetType.IsGenericType)
if (targetType.IsGenericType)
{
if (targetTypeType.GetGenericTypeDefinition() == typeof(Dictionary<,>))
return new DictionaryEditor();
@@ -118,6 +119,8 @@ namespace FlaxEditor.CustomEditors
if (customEditorType != null)
return (CustomEditor)Activator.CreateInstance(customEditorType);
}
if (typeof(FlaxEngine.Object).IsAssignableFrom(targetTypeType))
return new ScriptingObjectEditor();
// The most generic editor
return new GenericEditor();

View File

@@ -20,7 +20,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
/// </summary>
/// <seealso cref="FlaxEditor.CustomEditors.Editors.GenericEditor" />
[CustomEditor(typeof(Actor)), DefaultEditor]
public class ActorEditor : GenericEditor
public class ActorEditor : ScriptingObjectEditor
{
private Guid _linkedPrefabId;

View File

@@ -0,0 +1,29 @@
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
using FlaxEditor.CustomEditors.Editors;
using FlaxEngine.Networking;
namespace FlaxEditor.CustomEditors.Dedicated
{
/// <summary>
/// Custom editor for <see cref="FlaxEngine.Object"/>.
/// </summary>
public class ScriptingObjectEditor : GenericEditor
{
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
{
// Network objects debugging
var obj = Values[0] as FlaxEngine.Object;
if (Editor.IsPlayMode && NetworkManager.IsConnected && NetworkReplicator.HasObject(obj))
{
var group = layout.Group("Network");
group.Panel.Open();
group.Label("Role", Utilities.Utils.GetPropertyNameUI(NetworkReplicator.GetObjectRole(obj).ToString()));
group.Label("Owner Client Id", NetworkReplicator.GetObjectOwnerClientId(obj).ToString());
}
base.Initialize(layout);
}
}
}

View File

@@ -3,7 +3,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using FlaxEditor.Actions;
using FlaxEditor.Content;
using FlaxEditor.GUI;

View File

@@ -78,7 +78,7 @@ namespace FlaxEditor.CustomEditors.Editors
/// <seealso cref="FlaxEditor.CustomEditors.Editors.Float3Editor" />
public class ScaleEditor : Float3Editor
{
private Image _linkImage;
private Button _linkButton;
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
@@ -87,19 +87,20 @@ namespace FlaxEditor.CustomEditors.Editors
LinkValues = Editor.Instance.Windows.PropertiesWin.ScaleLinked;
_linkImage = new Image
// Add button with the link icon
_linkButton = new Button
{
BackgroundBrush = new SpriteBrush(Editor.Instance.Icons.Link32),
Parent = LinkedLabel,
Width = 18,
Height = 18,
Brush = LinkValues ? new SpriteBrush(Editor.Instance.Icons.Link32) : new SpriteBrush(),
AnchorPreset = AnchorPresets.TopLeft,
TooltipText = "Scale values are linked together.",
};
_linkButton.Clicked += ToggleLink;
SetLinkStyle();
var x = LinkedLabel.Text.Value.Length * 7 + 5;
_linkImage.LocalX += x;
_linkImage.LocalY += 1;
_linkButton.LocalX += x;
_linkButton.LocalY += 1;
LinkedLabel.SetupContextMenu += (label, menu, editor) =>
{
menu.AddSeparator();
@@ -127,7 +128,16 @@ namespace FlaxEditor.CustomEditors.Editors
{
LinkValues = !LinkValues;
Editor.Instance.Windows.PropertiesWin.ScaleLinked = LinkValues;
_linkImage.Brush = LinkValues ? new SpriteBrush(Editor.Instance.Icons.Link32) : new SpriteBrush();
SetLinkStyle();
}
private void SetLinkStyle()
{
var style = FlaxEngine.GUI.Style.Current;
var backgroundColor = LinkValues ? style.Foreground : style.ForegroundDisabled;
_linkButton.SetColors(backgroundColor);
_linkButton.BorderColor = _linkButton.BorderColorSelected = _linkButton.BorderColorHighlighted = Color.Transparent;
_linkButton.TooltipText = LinkValues ? "Unlinks scale components from uniform scaling" : "Links scale components for uniform scaling";
}
}
}

View File

@@ -541,7 +541,7 @@ namespace FlaxEditor.Windows
{
ref var line = ref lines[j];
textBlock.Range.StartIndex = startIndex + line.FirstCharIndex;
textBlock.Range.EndIndex = startIndex + line.LastCharIndex;
textBlock.Range.EndIndex = startIndex + line.LastCharIndex + 1;
textBlock.Bounds = new Rectangle(new Float2(0.0f, prevBlockBottom), line.Size);
if (textBlock.Range.Length > 0)
@@ -550,7 +550,7 @@ namespace FlaxEditor.Windows
var regexStart = line.FirstCharIndex;
if (j == 0)
regexStart += prefixLength;
var regexLength = line.LastCharIndex - regexStart;
var regexLength = line.LastCharIndex + 1 - regexStart;
if (regexLength > 0)
{
var match = _compileRegex.Match(entryText, regexStart, regexLength);