#How to exclude child renderers from a parent.
1 messages · Page 1 of 1 (latest)
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)))?
yes, no
Also the obligatory hint that using Find is bad from performance, code-design, and reliability standpoints.
no because that is just a different way of using the same code
and?
how else would i mod a game without find
Since I don't know what (other) technique(s) you are using to mod it in the first place, I cannot quite answer this.
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
Okay.
Since you are enabling all the renderers in your first code snippet, I assume that they are disabled by default? If so, you will need to pass true into GetComponentsInChildren for it to also find them.
https://docs.unity3d.com/ScriptReference/Component.GetComponentsInChildren.html
no they would be disabled by the first foreach loop
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
Alright, let me rephrase: "they are, or may be, disabled before you try finding the ones you want to keep enabled?"
the bottom is what i want to do, but it doesnt select the correct objects
yes
Since the 1st loop disables all Renderers under Environment, the GetComponentsInChildren calls in the 2nd and 3rd loops will not return any.
but the top code "works"
why do you keep coming back to this, the first snippet does what i want it to do for my mod specifically
you are pointing out that the top one wont work, but it does
So the other renderers do get re-enabled again fine?
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
@worthy violet after testeing every case, it does work
How did you end up implementing it?
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)