Add tooltips to actors in scene tree and to properties General panel header

#182
This commit is contained in:
Wojciech Figat
2021-12-09 17:10:34 +01:00
parent 2b1e5e4958
commit 141022caf8
2 changed files with 19 additions and 1 deletions

View File

@@ -47,7 +47,8 @@ namespace FlaxEditor.CustomEditors.Dedicated
public override void Initialize(LayoutElementsContainer layout)
{
// Check for prefab link
if (Values.IsSingleObject && Values[0] is Actor actor && actor.HasPrefabLink)
var actor = Values.Count == 1 ? Values[0] as Actor : null;
if (actor != null && actor.HasPrefabLink)
{
// TODO: consider editing more than one instance of the same prefab asset at once
@@ -91,6 +92,8 @@ namespace FlaxEditor.CustomEditors.Dedicated
{
if (layout.Children[i] is GroupElement group && group.Panel.HeaderText == "General")
{
if (actor != null)
group.Panel.TooltipText = Surface.SurfaceUtils.GetVisualScriptTypeDescription(TypeUtils.GetObjectType(actor));
const float settingsButtonSize = 14;
var settingsButton = new Image
{

View File

@@ -201,6 +201,21 @@ namespace FlaxEditor.SceneGraph.GUI
base.Update(deltaTime);
}
/// <inheritdoc />
protected override bool ShowTooltip => true;
/// <inheritdoc />
public override bool OnShowTooltip(out string text, out Vector2 location, out Rectangle area)
{
// Evaluate tooltip text once it's actually needed
var actor = _actorNode.Actor;
if (string.IsNullOrEmpty(TooltipText) && actor)
TooltipText = Surface.SurfaceUtils.GetVisualScriptTypeDescription(TypeUtils.GetObjectType(actor));
return base.OnShowTooltip(out text, out location, out area);
}
/// <inheritdoc />
protected override Color CacheTextColor()
{