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
- [WebGL][Android] Corrupt header when connecting via IP
- Editor and Android Player hangs/freezes when repeatedly Loading/Unloading AssetBundle in Vulkan
- Selecting a Material for HDRP Decal Projector in the Inspector window spams errors in the Console
- Expanded Asset Preview Box moves/hides when creating new Asset in Project window
- Player crashes on Meta Quest with "/apex/com.android/runtime/lib64/bionic/libc.so" when using OpenXR Plugin in a specific project
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);
}
}