Search Issue Tracker
By Design
Votes
1
Found in
2021.2
2021.2.0f1
2022.1
Issue ID
1378385
Regression
No
Can't create a new button for each element of the list when using ScriptableObject script
Reproduction steps:
1. Open the user's attached project
2. Select Assets > Plugins > Scripts > "Skills" ScriptableObject
3. Open the "Relies On Skills" list and add new items
Expected result: List full of buttons
Actual result: One Button in the list
Reproduced in: 2021.2.5f1, 2022.1.0b1
Could not test with: 2019.4.33f1, 2020.3.23f1 (error about an inability to change string to char)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Rendering Debugger window sections do not have a minimum width set when resizing with the slider in the middle of the window
- Last segment of a Sprite Shape Spline is affected by other segments' Sprite Variant change when no edge Sprite is selected
- [iOS] Application frequently crashes on Social.LoadAchievements call when many achievements are registered
- Errors “RenderPass: Attachment 0 is declared as depth attachment but RGBA8 sRGB is not a valid depth format.“ and “BeginSubPass: Not inside a Renderpass“ are present when using Native RenderPass with a RenderTexture that only has depth output
- ArgumentOutOfRangeException is thrown when an empty DropdownField is clicked at runtime
Resolution Note:
Since PropertyDrawers are shared between all instances, CreatePropertyGUI() needs to always returns a new VisualElement. Here is a modified version of the custom property drawer that will allow you to edit each value independently.
[CustomPropertyDrawer(typeof(SkillHolderSerialized), true)]
public class SkillHolderSerializedDrawer : PropertyDrawer
{
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
var container = new VisualElement();
CreateSkillEditor(container, "skill.");
return container;
}
public static void CreateSkillEditor(VisualElement container, string bindingPathPrefix)
{
var uuid = new IntegerField()
{
label = "Uuid",
bindingPath = $"{bindingPathPrefix}{nameof(Skill.uuid)}"
};
container.Add(uuid);
var nameField = new TextField()
{
label = "Skill Name",
bindingPath =$"{bindingPathPrefix}{nameof(Skill.skillName)}"
};
container.Add(nameField);
var descriptionField = new TextField()
{
label = "Skill Description",
bindingPath = $"{bindingPathPrefix}{nameof(Skill.skillDescription)}",
multiline = true
};
container.Add(descriptionField);
}
}