-
Notifications
You must be signed in to change notification settings - Fork 138
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Sometimes I want to use an attribute, but I wish to apply it onto a field of the serialized field's type, instead of the serialized field itself. Here's an example:
public interface IObjectWrapper
{
Object WrappedObject { get; }
}
public class SerializedInterface<TInterface> : IObjectWrapper
{
[SerializeField] privare Object _underlyingValue;
Object IObjectWrapper.WrappedObject => _underlyingValue;
//...
}
public class MyScript : MonoBehaviour
{
[SerializeField, NotNull]
private SerializedInterface<MyInterface> _requiredInterface;
[SerializeField]
private SerializedInterface<MyInterface> _nonRequiredInterface;
// _requiredInterface's drawer will be annotated with the "Variable has to be assigned" message when it's _underlyingValue is not set.
}From my understanding, something like this is not achievable with the current structure, unless applying the NotNull attribute directly to the _underlyingValue inside SerializedInterface.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request