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
  Volume Spots and Distance from generator topquarkone 5 184 09-16-2021, 08:17 PM
Last Post: _Aka_
  Spot Generator resetting some values after Script compilation Mos Def 11 1,904 05-25-2021, 02:41 PM
Last Post: _Aka_
  save spot generated gameobject to scene fortune53 1 456 03-18-2021, 06:25 PM
Last Post: _Aka_
  Spot generator range change Mos Def 4 882 02-24-2021, 07:32 PM
Last Post: Mos Def

Forum Jump: