35 lines
935 B
C#
35 lines
935 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
[RequireComponent(typeof(Inventory))]
|
|
public class InventoryPack : MonoBehaviour {
|
|
|
|
public GameObject[] items;
|
|
|
|
// Use this for initialization
|
|
void Start () {
|
|
var inventory = GetComponent<Inventory>();
|
|
|
|
if (items != null && items.Length > 0) {
|
|
foreach (var item in items) {
|
|
var pickable = item.GetComponent<PickableItem>();
|
|
if (pickable != null) {
|
|
var clone = Instantiate(item);
|
|
var pi = clone.GetComponent<PickableItem>();
|
|
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 () {
|
|
|
|
}
|
|
}
|