private static void MoveAvatarAttachPoint(IWeaponAttacher avatar, string weaponAttachPointTransPath, string avatarAttachPointName, Transform protoTrans) { Transform from = protoTrans.Find(weaponAttachPointTransPath); Transform attachPoint = avatar.GetAttachPoint(avatarAttachPointName); CopyTransformLocalProperties(from, attachPoint); }
private static void DetachWeaponAttachPoint(IWeaponAttacher avatar, string attachPoint) { Transform transform = avatar.GetAttachPoint(attachPoint); transform.GetComponent <MeshFilter>().sharedMesh = null; transform.GetComponent <MeshRenderer>().sharedMaterials = new Material[0]; }
private static Transform AttachPartToAttachPoint(IWeaponAttacher avatar, string partPath, string attachPoint, Transform protoTrans) { Transform transform = avatar.GetAttachPoint(attachPoint); GameObject gameObject = protoTrans.Find(partPath).gameObject; if (gameObject.GetComponent <MeshFilter>() == null) { transform.GetComponent <MeshFilter>().sharedMesh = null; return(transform); } transform.GetComponent <MeshFilter>().sharedMesh = gameObject.GetComponent <MeshFilter>().sharedMesh; transform.GetComponent <MeshRenderer>().sharedMaterials = gameObject.GetComponent <MeshRenderer>().sharedMaterials; return(transform); }
private static void DeleteAttachPointChildren(IWeaponAttacher avatar, string attachPoint, bool onlyMeshChild = true) { Transform transform = avatar.GetAttachPoint(attachPoint); int index = 0; while (transform.childCount > index) { if (onlyMeshChild && (transform.GetChild(index).GetComponent <MeshRenderer>() == null)) { index++; } else { UnityEngine.Object.DestroyImmediate(transform.GetChild(index).gameObject); } } }