小编Nid*_*ere的帖子

How to declare events inside a dictionary initialization?

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)

c#

3
推荐指数
1
解决办法
131
查看次数

unity Resources.Load &lt;Sprite&gt; 返回 null

是的,我已经阅读了所有有类似问题的主题。但是我的还没有解决:(

那你能看一下吗?

像其他人一样,我正在尝试通过代码更改对象的精灵。精灵文件本身位于“资产/资源”文件夹中。导入设置声明导入文件的纹理类型为“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)”替换了现有的对象精灵,我猜这意味着“空”。

任何帮助将非常感激!

c# sprite unity-game-engine

2
推荐指数
1
解决办法
3321
查看次数

如何将 ARRAYFORMULA 与 OFFSET 结合使用?

有什么想法为什么这不起作用?我需要自动填充 J 列。如果我只是延伸公式,它就可以正常工作。但是我需要它根据 G 列中的元素数量动态调整其大小

在此输入图像描述

这甚至可以实现吗?

google-sheets

2
推荐指数
1
解决办法
4944
查看次数

标签 统计

c# ×2

google-sheets ×1

sprite ×1

unity-game-engine ×1