一、脚本编程
1、创建背包物品数据
1)、在DataCollection添加struck结构体
[System.Serializable]
public struct InventoryItem
{
public int itemID;
public int itemAmount;
}
2、创建背包物品数据列表
1)、创建InventoryBag_SO文件
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "InventoryBag_SO", menuName = "Inventory/InventoryBag_SO")]
public class IventoryBag_SO : ScriptableObject
{
public List<InventoryItem> itemList;
}
3、实现将变化参数传入数据列表
1)、再编辑IventoryManager脚本文件
InventoryItem newItem = new InventoryItem() ;
newItem.itemID = item.itemID ;
newItem.itemAmount = 1;
PlayerBag.itemList[0]= newItem ;
二、开发操作
1、创建InventoryBag_SO类型文件重命名为PlayerBag文件

2、把PlaterBag拖拽到背包数据上

三、初步了解脚本编程
未完待续......
阅读更多作者文章:
Unity3D 游戏开发:Unity3D 游戏开发:脚本编程使地图中显示背包数据(19)