Wye*_*ott 1 events unity-game-engine
我在 Unity 2017 中有一个类,它只显示了检查器中的一些公共方法。
using System.Collections.Generic;
using UnityEngine;
public class Inventory : MonoBehaviour
{
List<ShipPart> _inventory;
int currentInvPosition = 0;
bool invExists = false;
// Use this for initialization
void Start () {
CreateInventory(0, 0);
}
// Show all inventory parts as gameobjects
public void CreateInventory(int quality, int part)
{
...
}
void DestroyInventory()
{
...
}
public void ScrollInvLeft()
{
...
}
public void ScrollInvRight()
{
...
}
void UpdateInv(float offset)
{
...
}
public void AddInventoryItem(ShipPart newShipPart)
{
...
}
public void RemoveInventoryItem(ShipPart oldShipPart)
{
...
}
public void Test1(){}
public void Test2(int i){}
}
Run Code Online (Sandbox Code Playgroud)
我想可能是因为不可见的方法有参数,所以我添加了最后两个方法。但是它们在检查器中是可见的!
我试图从下拉 UI 元素调用方法,但也从按钮进行了测试,但也看不到它们。
我究竟做错了什么?
如Unity官方教程中所述,如果您想在inspector中为事件提供一个函数,该函数必须满足以下要求:
publicvoidintfloatstringboolUnityEngine.Object, 或任何继承自的类型UnityEngine.Object(例如GameObject, MonoBehaviour, ScriptableObject, ...)