Arvtesh / UnityFx.Outline

Screen-space outlines for Unity3d.
MIT License
1.27k stars 90 forks source link

Remove object from layer? #15

Closed Noxalus closed 4 years ago

Noxalus commented 4 years ago

Hello!

From the documentation, there is an example of how to add GameObject to a specific layer from an OutlineEffect component:

var outlineEffect = Camera.main.GetComponent<OutlineEffect>();
outlineEffect.AddGameObject(myGo);

My question is: how can we remove this GameObject from the outline effect when we don't want the outline anymore?

In my case, I would like to outline the object when it's selected, and hide the outline if it's not selected anymore.

It couldn't be needed to have a method like this to do what I want, but I don't know how to do it 🤔

Thanks in advance for your help!

Arvtesh commented 4 years ago

Adding a game object to outline effect like that actually adds it to the 1st layer of the attached outline layer collection. So what you could do to remove it is: outlineEffect.OutlineLayers[0].Remove(myGo);

Noxalus commented 4 years ago

Thanks a lot for your answer! I didn't saw the propery for the OutlineLayer from the OutlineEffect class.

Thank you very much for the commit too, it still makes sense to have a method to inverse the AddGameObject action. 👍