Posts: 5
Threads: 2
Joined: Feb 2021
Hi,
Quick query before I figure out a workaround to this: I'm setting the Layer on the Create GameObject module, with the intention that generated spot GO's will be set to that layer upon creation. However, I'm seeing that the children of the 'parent' GO used as Input GameObjects are not also changed to the layer selected there. I'm sure I can iterate over the output GO's myself, but this seems like a slight oversight for those wanting to use GO's with LOD's under a parent transform, etc. Am I missing an option somewhere?
Thanks again
Lee
Posts: 2,077
Threads: 88
Joined: Jun 2017
You are probably not missing an option, and this is probably a bug. I will look at this soon
Please consider leaving a
review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Posts: 2,077
Threads: 88
Joined: Jun 2017
Sorry I misread what you said. The option you need is in in the Create GameObject module
Please consider leaving a
review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Posts: 5
Threads: 2
Joined: Feb 2021
Sorry, let me clarify: I'm using prefabs as the input to the Volume Spot module, where the parent GO has two children each with different LOD meshes. The Create GameObject module has the option to change the output layer of these GO's, which works fine, but it only changes the parent GO, and NOT the two children GO. The CreateObject module option to set the layer seems to change only the actual GO in the Input GameObjects module, and ignores any children GO they have.
Posts: 2,077
Threads: 88
Joined: Jun 2017
Ok, I see now. I will have a look at this soon. Will keep you updated
Please consider leaving a
review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Posts: 2,077
Threads: 88
Joined: Jun 2017
Hi
Can you please confirm to me that the following fixed your issue?
Go to CreateGameObject.cs
Find this line:
Code:
res.gameObject.layer = Layer;
Add underneath the following
Code:
for (int i = 0; i < res.childCount; i++)
res.GetChild(i).gameObject.layer = Layer;
Please consider leaving a
review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Posts: 5
Threads: 2
Joined: Feb 2021
08-05-2021, 04:55 PM
(This post was last modified: 08-05-2021, 04:59 PM by leeharris.)
Hi, sorry I neglected to check back in here. I actually implemented something very similar at the code location you stated.
childCount only counts the immediate children of the parent, though, so that will work fine as long as the hierarchy isn't too complex. I added this instead, and it seems to work without any obvious issues:
Code:
Transform[] ts = res.GetComponentsInChildren<Transform>(true);
foreach (Transform t in ts)
t.gameObject.layer = Layer;
I'm presuming GetChild and GetComponentsInChildren don't differ too much in terms of performance.
Thanks for getting back to me!
Posts: 2,077
Threads: 88
Joined: Jun 2017
Thanks for sharing that improvement. Regarding performance, I guess GetChild would be faster, but I have to test to know for sure, and more importantly if so, by how much
Please consider leaving a
review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Posts: 2,077
Threads: 88
Joined: Jun 2017
GetComponentsInChildren does an allocation to make the array, which GetChild doesn't need. So an alternative would be to make a recursive method that goes through all children an apply an action on them. For now, I will just stick with the simplest implementation, using GetComponentsInChildren, and will optimize it if needed
Please consider leaving a
review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.