Unity手册SpriteAtlasManager翻译

SpriteAtlasManager

命名空间:UnityEngine.U2D

描述:
在运行时管理SpriteAtlas
可以在不引用任何Sprite Atlas的情况下加载Sprite,这样的结果是没有纹理。在用户通过监听SpriteAtlasManager.atlasRequested回调将图集注册到Sprite之前,它将是不可见的。触发时,它将传入atlas tagSystem.Action,它将接收一个atlas对象.

事件:

事件描述
atlasRegisteredSpriteAtlasManager.atlasRequested中调用回调来注册SpriteAtlas时触发
atlasRequested当任何Sprite绑定到SpriteAtlas但在运行时无法找到atlas asset 时触发。

使用时发现的细节:
altasRequested 是在Start之后调用,即在即将显示的时候,atlasRegistered是在altasRequested使用回调后调用.

altasRequested 即使该精灵绑定的sprite atlas已经存在,还是会触发该事件.


另外还发现了一个Unitybug,??操作符有bug在2018.4.8版本中

public class Test : MonoBehaviour
{
    public Text Text; // text已序列化
    public Font Font;// null
    void Start()
    {
        Text.font = Font == null ? Text.font : Font; //  正确.text.font 没改变
        //Text.font = Font ?? Text.font; // 错误.text.font会变成null,但这个写法是上面的简化版本
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

bug的QA反馈,说是没有重载??操作符,所以以后还是得注意不能对Unity.Object使用??操作符。

Hi,
Thank you for contacting us about your issue.
Such behavior is expected. Null objects in Unity are not equal to null from the C# perspective, therefore, you get such results. The other line works correctly because it uses '==' operator, which is overloaded in Unity to make Unity null equal to C# null. There is no such overload for '??' operator, so you get Text.font set to null.


这段时间,一直都比较忙,没多少时间写博客学习东西,不断地在人生的漩涡中挣扎,不知这样是否真的会改变什么...

转载于:https://www.cnblogs.com/Fallever/p/11482848.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值