using System.Collections.Generic; using UnityEngine; // ±£´æËùÓÐ14¸ö¹Ç÷À public class RigidbodyHolder : MonoBehaviour { private Rigidbody[] allRigs; private WeaponHandler weapons; private void Start() { allRigs = GetComponentsInChildren(); weapons = GetComponent(); } private void Update() { } public Rigidbody[] GetAllRigs() { if (!weapons.leftGun && !weapons.rightGun) { return allRigs; } List list = new List(); for (int i = 0; i < allRigs.Length; i++) { list.Add(allRigs[i]); } if ((bool)weapons) { if ((bool)weapons.leftGun) { list.Add(weapons.leftGun.rig); } if ((bool)weapons.rightGun) { list.Add(weapons.rightGun.rig); } } return list.ToArray(); } }