unity 显示mipmaplevel
Posted minggoddess
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了unity 显示mipmaplevel相关的知识,希望对你有一定的参考价值。
https://docs.unity3d.com/ScriptReference/Texture2D.SetPixels.html
显示mipmaplevel 需要贴图可读写不压缩
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { void Start() { Renderer rend = GetComponent<Renderer>();
// duplicate the original texture and assign to the material Texture2D texture = Instantiate(rend.material.mainTexture) as Texture2D; rend.material.mainTexture = texture;
// colors used to tint the first 3 mip levels Color[] colors = new Color[3]; colors[0] = Color.red; colors[1] = Color.green; colors[2] = Color.blue; int mipCount = Mathf.Min(3, texture.mipmapCount);
// tint each mip level for (int mip = 0; mip < mipCount; ++mip) { Color[] cols = texture.GetPixels(mip); for (int i = 0; i < cols.Length; ++i) { cols[i] = Color.Lerp(cols[i], colors[mip], 0.33f); } texture.SetPixels(cols, mip); } // actually apply all SetPixels, don‘t recalculate mip levels texture.Apply(false); } }
以上是关于unity 显示mipmaplevel的主要内容,如果未能解决你的问题,请参考以下文章
Unity报错:Read only asset Packages/com.xxxxx.xxx.xxxx/Editor/VSCodeDiscovery.cs.IPGSD has no meta(代码片段
Unity报错:Read only asset Packages/com.xxxxx.xxx.xxxx/Editor/VSCodeDiscovery.cs.IPGSD has no meta(代码片段