UnityFx.Outline icon indicating copy to clipboard operation
UnityFx.Outline copied to clipboard

Explicitly set renderers on OutlineBehaviour

Open STARasGAMES opened this issue 3 years ago • 10 comments

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 avatar Jul 24 '21 14:07 STARasGAMES

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 :)

STARasGAMES avatar Jul 24 '21 16:07 STARasGAMES

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?

Arvtesh avatar Jul 24 '21 18:07 Arvtesh

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

STARasGAMES avatar Jul 24 '21 19:07 STARasGAMES

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?

Arvtesh avatar Aug 17 '21 09:08 Arvtesh

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.

STARasGAMES avatar Aug 17 '21 09:08 STARasGAMES

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

Arvtesh avatar Aug 17 '21 09:08 Arvtesh

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

STARasGAMES avatar Aug 17 '21 10:08 STARasGAMES

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).

Arvtesh avatar Aug 23 '21 08:08 Arvtesh

@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.

insominx avatar Jul 12 '22 22:07 insominx

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

Arvtesh avatar Jul 13 '22 06:07 Arvtesh