Search the Community
Showing results for tags 'transform'.
-
Is there any way to figure out what transforms are avaialbe on a part model. Until now I have only seen how to acces a transform on a part module you know the name of, or though it parent, but what if you don't know the name. Is there any utility, trick or c# code I can list all possible transform objects on a model? Is there some root Transform on a part I might get access to it child transforms?
-
To elaborate : I'm writing a plugin that will read part.cfg to get a transform for a part's sub-object. There is part.FindModelTransform() but it relies on transform's name being unique. The plugin i'm writing will be released to be used by part creators and will read transform name from part.cfg, so i don't have control over what gets entered. What i want is to use part.transform.Find() that can use full path to named transform but so far i had no luck on my demo part. I tried to recursively build a path from transform to its parents by concatenating their names and it didn't work. I did find an older post about pretty much the same problem and it did show some clear examples but it didn't work for me. Here is example code i tried : Transform partTransform = part.FindModelTransform("gate_shield_root"); string transformPath = partTransform.name; while (partTransform.parent != null) { partTransform = partTransform.parent; transformPath = partTransform.name + "/" + transformPath; } Debug.Log ("path = " + transformPath); Debug.Log("find() = " + (transform.Find(transformPath) != null).ToString()); This printed out HX1AerodynamicGateShell/model/0000_MyParts/HX_1_Aerodynamic_Gate_Shell/model(Clone)/base/gate_shield_root and Find() failed on that one. In Unity, my model hierarchy looks like this (names are as seen in hierarchy view) : GameObject > base > gate_shield_root The only clue how a path should look like in the above mentioned post was this (extra spaces for clarity) model / Your_Game_Object_In_Unity / Root_Object_In_Model / Sub_Object / ... / Sub_Object_WIth_Needed_Transform