Any way to make this work with Odin?
See original GitHub issueHey, Thanks for making this!
I’m having trouble with this step in the installation instructions: “Alternatively, you can apply MarkedUpEditor to all classes that inherit from MonoBehaviour or ScriptableObject and don’t have their own custom editor:”
[CustomEditor(typeof(MonoBehaviour), true), CanEditMultipleObjects]
internal class MarkedUpMonoBehaviourEditor : MarkedUpEditor
{
}
[CustomEditor(typeof(ScriptableObject), true), CanEditMultipleObjects]
internal class MarkedUpScriptableObjectEditor : MarkedUpEditor
{
}
I tried putting this in an editor script, but I still can’t use markup attributes in my monobehaviours. For example, even if I tag a field as ReadOnly, it still displays as a normal editable field.
Meanwhile, I tried applying the script to a single class, and it worked. Like this:
[CustomEditor(typeof(LockedDoor)), CanEditMultipleObjects]
internal class LockedDoorEditor : MarkedUpEditor
{
}
In the LockedDoor class, I have a field that looks like this
[SerializeField, ReadOnly] bool canBeRelocked = false;
Using the second example, the ReadOnly attribute works as expected.
After a quick test in an empty project, it seems that this problems only occurs when Odin is present in the project (even if Sirenix is not implemented in that particular script). Is there any way this asset can work with Odin in the project without having to create a separate MarkedUpEditor class for every component that I want to use it with? I’m interested in Odin alternatives, but my project isn’t prepared to just remove it outright.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
MarkupAttributes doesn’t change anything about Unity serialization. It’s a purely UI package. And it only applies its inspector to a class if you tell it to do so. You can tell it to aplly its inspector to all MonoBehaviours and SerializedObjects, as described in the Usage part of the readme. Odin has something like this in its codebase by default.
Got it; thanks!