using UnityEngine; using System.Collections; [RequireComponent(typeof(Inventory))] public class InventoryPack : MonoBehaviour { public GameObject[] items; // Use this for initialization void Start () { var inventory = GetComponent(); if (items != null && items.Length > 0) { foreach (var item in items) { var pickable = item.GetComponent(); if (pickable != null) { var clone = Instantiate(item); var pi = clone.GetComponent(); if (pi.sensor != null) { pi.sensor.enabled = false; pi.sensor.sensorEnabled = false; } inventory.AddItem(pi); Debug.Log("InventoryPack add item: " + clone.name); } } } } // Update is called once per frame void Update () { } }