#How to exclude child renderers from a parent.

1 messages · Page 1 of 1 (latest)

fresh dirge
#

the thing is with the top one, if other mods disable any of the child renders in PlayersPlace or CoreLighting, my mod would just undo it, which it why im trying to figure out how to exclude it, vs setting it true

worthy violet
#

Did you actually modify your code to use GetEnvironmentRenderers() in your loop?
If so, have you tried changing your linq query to environmentRenderers.Where(r => (!playersPlaceRenderers.Contains(r) && !coreLightingRenderers.Contains(r)))?

worthy violet
#

Also the obligatory hint that using Find is bad from performance, code-design, and reliability standpoints.

fresh dirge
#

no because that is just a different way of using the same code

fresh dirge
#

how else would i mod a game without find

worthy violet
fresh dirge
#

you cant get objects in a game without using find, that was a rhetorical question

#

i could use Harmony, but that works for classes not objects in a scnee

worthy violet
fresh dirge
#

well, if the config for the mod disables them

#

the top code does what i want it to do, minus the reforcing it to be true

worthy violet
#

Alright, let me rephrase: "they are, or may be, disabled before you try finding the ones you want to keep enabled?"

fresh dirge
#

the bottom is what i want to do, but it doesnt select the correct objects

worthy violet
#

Since the 1st loop disables all Renderers under Environment, the GetComponentsInChildren calls in the 2nd and 3rd loops will not return any.

fresh dirge
#

but the top code "works"

fresh dirge
#

you are pointing out that the top one wont work, but it does

worthy violet
#

So the other renderers do get re-enabled again fine?

fresh dirge
#

yes

#

wait

#

i just had an idea

#

gimme like, 30 minutes to test if it works lol

#

i think i may have been overthinkign this structure

#

ok i think it is going to work

#

i remembered that i was going to split up the 3 things into different option anyway, instead of just having them all be set at the same time

#

now if i just make sure that the right order is set, it should work

fresh dirge
#

@worthy violet after testeing every case, it does work

worthy violet
#

How did you end up implementing it?

fresh dirge
#

pretty much the same way

#

i just spit it up

#
public void Initialize()
    {
        this.environmentRenderers = GameObject.Find("Environment").GetComponentsInChildren<Renderer>();
        this.platformRenderers = GameObject.Find("Environment/PlayersPlace").GetComponentsInChildren<Renderer>();
        this.lightingRenderers = GameObject.Find("Environment/CoreLighting").GetComponentsInChildren<Renderer>();

        this.HideGameEnvironment(this.pluginConfig.HideGameEnvironment);
        this.HidePlatform(this.pluginConfig.HidePlatform);
        this.HideGameLighting(this.pluginConfig.HideGameLighting);
    }

    public void HideGameEnvironment(bool shouldHide)
    {
        foreach (Renderer renderer in this.environmentRenderers)
        {
            renderer.enabled = !shouldHide;
        }
    }

    public void HidePlatform(bool shouldHide)
    {
        foreach (Renderer renderer in this.platformRenderers)
        {
            renderer.enabled = !shouldHide;
        }
    }

    public void HideGameLighting(bool shouldHide)
    {
        foreach (Renderer renderer in this.lightingRenderers)
        {
            renderer.enabled = !shouldHide;
        }

        foreach (Renderer renderer in this.environmentRenderers)
        {
            if (renderer.GetComponent<LightManager>() == null && (renderer.name.Contains("bloom") || renderer.name.Contains("light")))
            {
                renderer.forceRenderingOff = shouldHide;
            }
        }
    }```
#

(the last foreach was in a seperate function that i didntt previosuly send, and i merged the two)