cakeslice / Outline-Effect

Outline Image Effect for Unity
MIT License
1.48k stars 201 forks source link

[Bug] lost Material references #52

Closed JeReT closed 3 years ago

JeReT commented 4 years ago

After cleaning up my camera prefab containing stuff of the outline effect, the Material references got lost and, although not in play mode, OnRenderImage has been called and spammed my console with null reference exception logs.

I solved the problem by adding the following lines to the class:

#if UNITY_EDITOR
        private void OnValidate()
        {
            CreateMaterialsIfNeeded();
        }
#endif

This way the materials where created as soon as I selected the GameObject containing the OutlineEffect.