版本:Unity 6 (6000.0)
语言英语
  • C#

FilterMode.Trilinear

提出更改建议

提交成功!

感谢您帮助我们提升 Unity 文档的质量。尽管我们无法接受所有反馈,但我们会阅读用户提出的每条更改建议,并在适用情况下进行更新。

关闭

提交失败

由于某些原因,您提出的更改建议无法提交。请在几分钟后<a>重试</a>。感谢您抽出时间帮助我们提升 Unity 文档的质量。

关闭

取消

说明

三线性过滤 - 平均纹理样本并且在渐进纹理级别之间混合纹理样本。

对于没有渐进纹理的纹理,此设置与 双线性 相同。

其他资源:Texture.filterMode纹理资源

//This script changes the filter mode of your Texture you attach when you press the space key in Play Mode. It switches between Point, Bilinear and Trilinear filter modes.
//Attach this script to a GameObject
//Click on the GameObject and attach a Texture to the My Texture field in the Inspector.
//Apply the Texture to GameObjects (click and drag the Texture onto a GameObject in Editor mode) in your Scene to see it change modes in-game.

using UnityEngine;

public class Example : MonoBehaviour { //Remember to assign a Texture in the Inspector window to ensure this works public Texture m_MyTexture;

void Update() { //Press the space key to switch between Filter Modes if (Input.GetKeyDown(KeyCode.Space)) { //Switch the Texture's Filter Mode m_MyTexture.filterMode = SwitchFilterModes(); //Output the current Filter Mode to the console Debug.Log("Filter mode : " + m_MyTexture.filterMode); } }

//Switch between Filter Modes when the user clicks the Button FilterMode SwitchFilterModes() { //Switch the Filter Mode of the Texture when user clicks the Button switch (m_MyTexture.filterMode) { //If the FilterMode is currently Bilinear, switch it to Point on the Button click case FilterMode.Bilinear: m_MyTexture.filterMode = FilterMode.Point; break;

//If the FilterMode is currently Point, switch it to Trilinear on the Button click case FilterMode.Point: m_MyTexture.filterMode = FilterMode.Trilinear; break;

//If the FilterMode is currently Trilinear, switch it to Bilinear on the Button click case FilterMode.Trilinear: m_MyTexture.filterMode = FilterMode.Bilinear; break; } //Return the new Texture FilterMode return m_MyTexture.filterMode; } }