Arvtesh / UnityFx.Outline

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

Explicitly set renderers on OutlineBehaviour #32

Open STARasGAMES opened 3 years ago

STARasGAMES commented 3 years ago

Is there a way to set renderers from the inspector? image

I would like to control this. Sometimes not all child objects should be outlined. Sometimes renderers are not child objects. I think that makes sense.

STARasGAMES commented 3 years ago

I was able to overcome this limitation by writing my own script based on OutlineBehaviour.cs. Still, it would be cool to have this feature out of the box. Feature request or smth :)

Arvtesh commented 3 years ago

You can set ignore layers value to exclude objects from rendering. OutlineBehaviour's purpose is rendering outline of a game object it is attached to. There are other tools if you need to do more complex outlines (like OutlineEffect + OutlineLayerCollection). Did you try them?

STARasGAMES commented 3 years ago

You can set ignore layers value to exclude objects from rendering.

Yeah, but I'm trying to avoid abusing layers.

OutlineBehaviour's purpose is rendering outline of a game object it is attached to. There are other tools if you need to do more complex outlines (like OutlineEffect + OutlineLayerCollection). Did you try them?

I looked at them but I didn't like this approach. I have a complete project that uses OutlineBehaviour-like script so for me it was easier to completely rewrite already used script with code from OutlineBehaviour with some changes to support explicit renderers setup. This way migration was easy as writing this script and not manually change every use of the old script.

. . Why I think OutlineBehaviour should support explicitly specified renderers: Consider a situation where we have an interactable door in the scene. When player looks at the door only the handle should be outlined, not the whole door. Yes, in some cases we could add OutlineBehaviour directly to handle and just use GetComponentInChildren<OutlineBehaviour>() instead of simply GetComponent from the door gameobject, but it's inconvenient and messes up the scene. IMHO

Arvtesh commented 3 years ago

There is OutlineBehaviour.OutlineRenderers property, which provides access to the OutlineBehaviour's list of renderers. So, while you cannot change the renderers from inspector, you can do that using simple script. Does that resolve the issue?

STARasGAMES commented 3 years ago

So, while you cannot change the renderers from inspector, you can do that using simple script.

Yes, I know that, I just don't see any reason why not to let users explicitly specify OutlineRenderers from the inspector. Just my opinion :)

As I wrote before, I solved my problem by writing my own script based on OutlineBehaviour. It was easy because you really nailed it, system design is so clean and decoupled.

Arvtesh commented 3 years ago

The reason is editor code required for such things, which I really hate writing :).

STARasGAMES commented 3 years ago

Ahh yes:)) Understandable) I could make PR if you confirm this feature

Arvtesh commented 3 years ago

Thank you, I think that's not nessesary. Most likely I'll bump minimum Unity version to 2020 LTS and use built-in arrays (they are presented as reorderable lists out of the box).

insominx commented 2 years ago

@Arvtesh It doesn't seem like this has happened yet. Do you have any plans to follow through? I have the same use case as @STARasGAMES and would greatly appreciate the change.

Arvtesh commented 2 years ago

Yes, as soon as I have time. Cannot give any estimates though.