1
This commit is contained in:
@@ -107,67 +107,59 @@ namespace BITKit
|
||||
{
|
||||
FillDefaultInspector(root, serializedObject, true);
|
||||
}
|
||||
public static void FillDefaultInspector(VisualElement container, SerializedObject serializedObject, bool hideScript)
|
||||
|
||||
protected static void FillDefaultInspector(VisualElement container, SerializedObject serializedObject, bool hideScript)
|
||||
{
|
||||
SerializedProperty property = serializedObject.GetIterator();
|
||||
if (property.NextVisible(true)) // Expand first child.
|
||||
var property = serializedObject.GetIterator();
|
||||
if (!property.NextVisible(true)) return; // Expand first child.
|
||||
do
|
||||
{
|
||||
do
|
||||
if (property.propertyPath == "m_Script" && hideScript)
|
||||
{
|
||||
if (property.propertyPath == "m_Script" && hideScript)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var type = serializedObject.targetObject.GetType().GetField(property.name);
|
||||
var field = new PropertyField(property);
|
||||
|
||||
|
||||
|
||||
field.name = "PropertyField:" + property.propertyPath;
|
||||
|
||||
|
||||
if (property.propertyPath == "m_Script" && serializedObject.targetObject != null)
|
||||
{
|
||||
field.SetEnabled(false);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (type is not null)
|
||||
{
|
||||
var header = type.GetCustomAttribute<HeaderAttribute>();
|
||||
if (header is not null)
|
||||
{
|
||||
Label label = new Label(header.header);
|
||||
label.AddToClassList("subTitle");
|
||||
container.Add(label);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
|
||||
Debug.LogException(e);
|
||||
}
|
||||
|
||||
|
||||
container.Add(field);
|
||||
continue;
|
||||
}
|
||||
while (property.NextVisible(false));
|
||||
|
||||
foreach (var method in serializedObject.targetObject.GetType().GetMethods())
|
||||
var type = serializedObject.targetObject.GetType().GetField(property.name);
|
||||
var field = new PropertyField(property)
|
||||
{
|
||||
if (method.GetCustomAttribute<BITAttribute>() is not null)
|
||||
{
|
||||
if (method.GetParameters().Length is 0)
|
||||
{
|
||||
var button = new Button(() => method.Invoke(serializedObject.targetObject, null));
|
||||
button.text = method.Name;
|
||||
name = "PropertyField:" + property.propertyPath
|
||||
};
|
||||
|
||||
container.Add(button);
|
||||
}
|
||||
}
|
||||
|
||||
if (property.propertyPath == "m_Script" && serializedObject.targetObject != null)
|
||||
{
|
||||
field.SetEnabled(false);
|
||||
}
|
||||
|
||||
// try
|
||||
// {
|
||||
// var header = type?.GetCustomAttribute<HeaderAttribute>();
|
||||
// if (header != null)
|
||||
// {
|
||||
// var label = new Label(header.header);
|
||||
// label.AddToClassList("subTitle");
|
||||
// container.Add(label);
|
||||
// }
|
||||
// }
|
||||
// catch (System.Exception e)
|
||||
// {
|
||||
// Debug.LogException(e);
|
||||
// }
|
||||
|
||||
|
||||
container.Add(field);
|
||||
}
|
||||
while (property.NextVisible(false));
|
||||
|
||||
foreach (var method in serializedObject.targetObject.GetType().GetMethods())
|
||||
{
|
||||
if (method.GetCustomAttribute<BITAttribute>() is null) continue;
|
||||
if (method.GetParameters().Length is not 0) continue;
|
||||
var button = new Button(() => method.Invoke(serializedObject.targetObject, null))
|
||||
{
|
||||
text = method.Name
|
||||
};
|
||||
|
||||
container.Add(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user