- Now correctly fetching signature and description for properties
- Minor code cleanup
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FlaxEditor.GUI.ContextMenu;
|
||||
using FlaxEditor.GUI.Input;
|
||||
using FlaxEditor.Scripting;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.GUI;
|
||||
using FlaxEngine.Utilities;
|
||||
@@ -638,15 +639,27 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
}
|
||||
|
||||
Profiler.BeginEvent("VisjectCM.SetDescriptionPanelArchetype");
|
||||
|
||||
_descriptionSignatureLabel.Text = archetype.Signature;
|
||||
|
||||
if (archetype.Tag is ScriptMemberInfo memberInfo)
|
||||
{
|
||||
var name = memberInfo.Name;
|
||||
if (memberInfo.IsMethod && memberInfo.Name.StartsWith("get_") || memberInfo.Name.StartsWith("set_"))
|
||||
{
|
||||
name = memberInfo.Name.Substring(4);
|
||||
}
|
||||
|
||||
_descriptionSignatureLabel.Text = memberInfo.DeclaringType + "." + name;
|
||||
}
|
||||
else
|
||||
_descriptionSignatureLabel.Text = archetype.Signature;
|
||||
|
||||
float panelHeight = _descriptionSignatureLabel.Height;
|
||||
|
||||
_descriptionLabel.Y = _descriptionSignatureLabel.Bounds.Bottom + 6f;
|
||||
_descriptionLabel.Text = archetype.Description;
|
||||
|
||||
panelHeight += _descriptionLabel.Height + 6f + 18f;
|
||||
|
||||
|
||||
_descriptionPanel.Height = panelHeight;
|
||||
Height = 400 + Mathf.RoundToInt(_descriptionPanel.Height);
|
||||
UpdateWindowSize();
|
||||
|
||||
@@ -440,7 +440,7 @@ namespace FlaxEditor.Surface
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
internal static string GetVisualScriptMemberInfoSignature(ScriptMemberInfo member, bool appendPropertyInfo = true)
|
||||
internal static string GetVisualScriptMemberInfoSignature(ScriptMemberInfo member)
|
||||
{
|
||||
var name = member.Name;
|
||||
var declaringType = member.DeclaringType;
|
||||
@@ -454,7 +454,7 @@ namespace FlaxEditor.Surface
|
||||
var property = declaringType.GetMembers(name.Substring(4), MemberTypes.Property, flags);
|
||||
if (property != null && property.Length != 0)
|
||||
{
|
||||
return GetVisualScriptMemberInfoDescription(property[0]);
|
||||
return GetVisualScriptMemberInfoSignature(property[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -483,7 +483,7 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
sb.Append(')');
|
||||
}
|
||||
else if (member.IsProperty && appendPropertyInfo)
|
||||
else if (member.IsProperty)
|
||||
{
|
||||
sb.Append(' ');
|
||||
sb.Append('{');
|
||||
@@ -500,6 +500,21 @@ namespace FlaxEditor.Surface
|
||||
|
||||
internal static string GetVisualScriptMemberShortDescription(ScriptMemberInfo member)
|
||||
{
|
||||
var name = member.Name;
|
||||
var declaringType = member.DeclaringType;
|
||||
|
||||
// Getter/setter method of the property - we can return early here
|
||||
bool isGetterOrSetter = name.StartsWith("get_") || name.StartsWith("set_");
|
||||
if (member.IsMethod && isGetterOrSetter)
|
||||
{
|
||||
var flags = member.IsStatic ? BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly : BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly;
|
||||
var property = declaringType.GetMembers(name.Substring(4), MemberTypes.Property, flags);
|
||||
if (property != null && property.Length != 0)
|
||||
{
|
||||
return GetVisualScriptMemberShortDescription(property[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return Editor.Instance.CodeDocs.GetTooltip(member);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user