public static AvatarPartInstance AssemblePart(NodeBehaviour nodeBehaviour, AvatarPartData partData) { AvatarPartInstance partInstance = new AvatarPartInstance(); partInstance.partName = partData.partName; partInstance.gameObjects = new GameObject[partData.prefabParts.Length]; for (int i = 0; i < partData.prefabParts.Length; ++i) { var prefabData = partData.prefabParts[i]; GameObject bindGameObject = GameObject.Instantiate(prefabData.prefabGO); Transform bindNodeTran = nodeBehaviour.GetBindTransform(prefabData.bindName); bindGameObject.transform.SetParent(bindNodeTran, false); partInstance.gameObjects[i] = bindGameObject; } partInstance.renderers = new SkinnedMeshRenderer[partData.rendererParts.Length]; for (int i = 0; i < partData.rendererParts.Length; ++i) { var rendererData = partData.rendererParts[i]; SkinnedMeshRenderer renderer = nodeBehaviour.GetSMRenderer(rendererData.rendererName); if (renderer != null) { SkinnedMeshRenderer smRenderer = renderer; smRenderer.rootBone = nodeBehaviour.GetBoneTransform(rendererData.rootBoneName); smRenderer.bones = nodeBehaviour.GetBoneTransformByNames(rendererData.boneNames); smRenderer.sharedMesh = rendererData.mesh; smRenderer.sharedMaterials = rendererData.materials; partInstance.renderers[i] = smRenderer; } else { DebugLog.Error("AvatarUtil", $"AvatarUtil::AssembleAvatarPart->nodeData not found.rendererNodeName={rendererData.rendererName}"); } } return(partInstance); }