dbrizov / NaughtyAttributes

Attribute Extensions for Unity
MIT License
4.53k stars 464 forks source link

[Request] Log errors in debug console #195

Open thibautvdu opened 3 years ago

thibautvdu commented 3 years ago

Description

Log contextualized errors in the debug console for the GUI errors, a bit like what we can achieve with Unity assert and OnValidate in Monobehaviours :

    private void OnValidate()
    {
        UnityEngine.Assertions.Assert.IsNotNull(MySerializedProperty);
    }

Why

It would be very convenient to open a scene and get a reference in the console to all the monobehaviours that do not fulfill the attribute requirements / specifications in the scene

I'd happily do it myself, but some hint/suggestion would be welcomed as I'm not used to work with the Editor that much.

dbrizov commented 3 years ago

What exactly do you want to do? I don't understand you.

thibautvdu commented 3 years ago

@dbrizov

Sorry if I wasn't clear. Basically, I would like to get the errors shown in the inspector in the console when opening / building a scene. Correct me if I'm wrong, but there is no easy way to know whether some monobehaviours fail fulfilling the naughty attributes requirements in the current scene without checking every gameobject manually.

If I have a [required] public MeshRenderer _meshRdr on some monobehaviours attached to a game object in my scene left to null, it would make sense to me to be able to track it down / get a warning about it

dbrizov commented 3 years ago

That's more clear now, thanks. I will do that :)

thibautvdu commented 3 years ago

@dbrizov awesome, thanks a lot :) I'm available for testing if necessary