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 will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
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 will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
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 will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
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 will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
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 will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
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 will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Volume Spots inter group distance Sacryn 1 3 02-27-2024, 04:08 PM
Last Post: _Aka_
  Newbie Question: Uniformly increase spacing between volume spots? SAMYTHEBIGJUICY 1 5 09-01-2023, 03:38 PM
Last Post: _Aka_
  Changing material of Volume spot at creation? _RicO 5 11 08-11-2023, 09:39 AM
Last Post: _Aka_
  Volume Spots not even when "drawing" spline too fast at runtime. _RicO 9 11 08-11-2023, 09:22 AM
Last Post: _Aka_

Forum Jump: