Simple and easy way to add a new button for create and attach an SO to another, this make easier to create abilities for cards in my game (removing the need of create the SO, find the card, and attach)
In Editor.cs
public class MyDataProcessor : OdinAttributeProcessor<MyData>
{
public override void ProcessChildMemberAttributes(InspectorProperty parentProperty, MemberInfo member, List<Attribute> attributes)
{
base.ProcessChildMemberAttributes(parentProperty, member, attributes);
if (member.Name == "abilities")
{
var attribute = attributes.GetAttribute<ListDrawerSettingsAttribute>();
attribute.OnTitleBarGUI = "@MyDataProcessor.CreateNewAbility($root)"; // could use $value to get Abilities[], or $root to get MyData
}
}
static private void CreateNewAbility(CardData value)
{
if (SirenixEditorGUI.ToolbarButton(SdfIconType.PlusCircleDotted))
{
ScriptableObjectCreator.ShowDialog<MyData>("Assets\\Resources\\abilities", obj =>
{
Array.Resize(ref value.abilities, value.abilities.Length + 1); // If you could, use a List instead
value.abilities[^1] = obj; // Append do not work well
});
}
}
}
In MyData.cs
[ListDrawerSettings()]
public MyData[] abilities;
Special thanks for Spiney on Odin's discord for all help.