Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Volume Spot GO layer - set children
#1
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 Smile

Lee
Reply
#2
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 helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply
#3
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 helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply
#4
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.
Reply
#5
Ok, I see now. I will have a look at this soon. Will keep you updated
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply
#6
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 helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply
#7
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!
Reply
#8
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 helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply
#9
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 helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Photo Volume Spots problem with spacing Bond007 1 3 12-05-2024, 11:17 PM
Last Post: _Aka_
  Duplicate Volume references become null joebain 5 33 11-18-2024, 10:46 AM
Last Post: joebain
  Nested Spline Volume Spot Instantiation merobbins5 3 7 07-26-2024, 09:58 AM
Last Post: _Aka_
  How to use CG Volume Controller j95677 5 12 07-17-2024, 07:15 PM
Last Post: j95677

Forum Jump: