I am creating a Dictionary of events and I want to declare those events inside the initialization of that dictionary instead of declaring them somewhere else and placing the links to the dictionary.
static event EventDelegate Event1;
static event EventDelegate Event2;
static event EventDelegate Event3;
public enum EventTypes
{
Event1,
Event2,
Event3,
}
public static Dictionary<EventTypes, EventDelegate> events = new Dictionary<EventTypes, EventDelegate>
{
{EventTypes.Event1, Event1},
{EventTypes.Event2, Event2},
{EventTypes.Event3, Event3},
};
Run Code Online (Sandbox Code Playgroud)
So I want to do something like that:
{EventTypes.Event1, new …Run Code Online (Sandbox Code Playgroud) 是的,我已经阅读了所有有类似问题的主题。但是我的还没有解决:(
那你能看一下吗?
像其他人一样,我正在尝试通过代码更改对象的精灵。精灵文件本身位于“资产/资源”文件夹中。导入设置声明导入文件的纹理类型为“Sprite(2D 和 UI)”。
我尝试了以下方法:
gameObject.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("1");
Run Code Online (Sandbox Code Playgroud)
和
gameObject.GetComponent<SpriteRenderer>().sprite = Resources.Load("1") as Sprite;
Run Code Online (Sandbox Code Playgroud)
和
Sprite s = Resources.Load("1") as Sprite;
gameObject.GetComponent<SpriteRenderer>().sprite = s;
Run Code Online (Sandbox Code Playgroud)
和
Sprite s = Resources.Load<Sprite>("1");
gameObject.GetComponent<SpriteRenderer>().sprite = s;
Run Code Online (Sandbox Code Playgroud)
他们都用“None(Sprite)”替换了现有的对象精灵,我猜这意味着“空”。
任何帮助将非常感激!