在添加纹理之前是否正在加载纹理?新纹理是如何存储的?通常,预缓存是在Awake()或Start()循环期间完成的.
Renderer objectRenderer;
public Texture2D replacementTextureAsset;
Texture2D runtimeTextureReplacement;
void Awake()
{
objectRenderer = (Renderer)GetComponent(typeof(Renderer));
// Either have the texture assigned via the inspector (replacementTextureAsset above)
// or else get a reference to it at runtime. Either way, the texture will be loaded into memory by the end of this loop.
runtimeTextureReplacement = Resources.Load("myReplacementAsset");
}
void TextureReplace() // Called whenever
{
objectRenderer.material.texture = replacementTextureAsset;
OR
objectRenderer.material.texture = runtimeTextureReplacement;
}
Run Code Online (Sandbox Code Playgroud)
如果这是你已经在做的并且你仍然有"滞后",那么你可能会遇到将纹理发送到图形卡上的帧缓冲区的不可避免的后果.在这种情况下,除了使用较小的纹理外,你无能为力.
归档时间: |
|
查看次数: |
8658 次 |
最近记录: |