【问题标题】:Is there any way to change FilterMode of custom Sprite in Unity?有什么方法可以改变 Unity 中自定义 Sprite 的 FilterMode?
【发布时间】:2020-06-07 13:17:07
【问题描述】:

我正在制作 2D 像素图形游戏,并希望通过 Texture2D 类使用自定义 Sprite。 所以我使用了这样的代码:

Sprite.Create(texture, new Rect(0, 0, size, size), new Vector2(0.5f, 0.5f), 32)

但是这个创建的精灵有FilterMode“双线性”。我想将其更改为“点(无过滤器)”。 在检查器中更改 FilterMode 非常简单,但我不知道如何在运行时更改它。有什么办法可以解决这个问题吗?

【问题讨论】:

    标签: unity3d sprite texture2d


    【解决方案1】:

    您只能更改纹理的过滤模式。

    texture.filterMode = FilterMode.Point;
    
    Sprite.Create(texture, new Rect(0, 0, size, size), new Vector2(0.5f, 0.5f), 32);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-01
      • 2013-03-05
      • 1970-01-01
      • 2011-11-29
      相关资源
      最近更新 更多