Arvtesh / UnityFx.Outline

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

Show and hide outline on Objects in URP #24

Closed ATHellboy closed 4 years ago

ATHellboy commented 4 years ago

Hey there, Thanks for the great outline effect.

I want to know how it is possible to enable and disable outline effect on objects in URP ? (For example when I select an Object it gets outlined and by deselecting it backs to normal)

Arvtesh commented 4 years ago

Hello, there are 2 ways of doing this:

  1. Create Unity layer (for instance MyOutlineLayer). Set it via Outline feature. Now all object assigned to the layer will be outlined.
  2. Use OutlineLayerCollection. Again Outline feature must have a reference to it. Now outlines would only render around objects in the collection.
ATHellboy commented 4 years ago

Hello, there are 2 ways of doing this:

  1. Create Unity layer (for instance MyOutlineLayer). Set it via Outline feature. Now all object assigned to the layer will be outlined.
  2. Use OutlineLayerCollection. Again Outline feature must have a reference to it. Now outlines would only render around objects in the collection.

Thanks for the reply. If I want to hide it, I should change the layer then ? Is it performant ?

About OutlinbeLayerCollection, this collection is accessible in a script in URP ?

Arvtesh commented 4 years ago

I'm not sure if changing layer at runtime is a heavy operation or not. I believe it's a bad idea to do this on each frame, changing it once a minute (for instance) should not impact app performance.

OutlineLayerCollection is a scriptable object. You can assign it in inspector both to outline feature and a MonoBehavoiur responsible for selecting objects.

ATHellboy commented 4 years ago

I don't get how I can add an object and remove an object from OutlineLayerCollection. There is no functionality about it. Just can add or remove layer.

Not sure if you get what I want. I want to make an object outlined when it is selected and remove the outline when it is deselected. And there are multiple objects in the scene and just those which are selected are outlined.

Arvtesh commented 4 years ago

As you said, OutlineLayerCollection is a collection of OutlineLayer instances. OutlineLayer, in turn, is a collection of game objects that share the same outline settings. You can add/remove game objects to OutlineLayer just as you do it with any other collection. There are shortcuts for adding/removing game objects to the first layer in OutlineLayerCollection as well.