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
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
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);
}
}