低調の美國生活

各種疑難雜症

使用連續圖檔並長時間播放之後產生貼圖模糊格狀問題

x492
4月3日2012年

1.模糊問題主要是貼圖設定問題:
產生MipMap取消
Aniso Level越高越不會糊
但要注意效能問題”
2.格狀問題(Pixelated)主要是貼圖格式
目前已知4×4沒問題
邊長為2的n次方”
不同的code可能會有不同情形
c# code參考:
using UnityEngine;
using System.Collections;

public class AnimatedTexture : MonoBehaviour
{

private float iX=0;
private float iY=1;
public int xCount = 1;
public int yCount = 1;
public int fps=3;
private Vector2 size;
private Renderer myRenderer;
private int lastIndex = -1;

void Start ()
{

size = new Vector2 (1.0f / xCount ,1.0f / yCount);

myRenderer = renderer;

if(myRenderer == null) enabled = false;

myRenderer.material.SetTextureScale (“_MainTex”, size);
}

void Update()
{

int index = (int)(Time.timeSinceLevelLoad * fps) % (xCount * yCount);
if(index != lastIndex)
{
Vector2 offset = new Vector2(iX*size.x,1-(size.y*iY));
iX++;
if(iX / xCount == 1)
{
iY++;
iX=0;
if(iY / yCount== 1)
{
iY=0;
}
}

myRenderer.material.SetTextureOffset (“_MainTex”, offset);

lastIndex = index;
}

}

}


發佈於 4月3日2012年