码迷,mamicode.com
首页 > 编程语言 > 详细

unity 显示mipmaplevel

时间:2018-11-29 12:22:43      阅读:399      评论:0      收藏:0      [点我收藏+]

标签:iat   text   贴图   tin   href   ocs   use   pix   actual   

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

标签:iat   text   贴图   tin   href   ocs   use   pix   actual   

原文地址:https://www.cnblogs.com/minggoddess/p/10037072.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!