Version: 2022.2

Handles.DrawTexture3DSlice

切换到手册
public static void DrawTexture3DSlice (Texture texture, Vector3 slicePositions, FilterMode filterMode= FilterMode.Bilinear, bool useColorRamp= false, Gradient customColorRamp= null);

参数

texture The volumetric texture to draw.
slicePositions The positions of the texture sampling planes.
filterMode Sets the texture filtering mode to use.
useColorRamp Enables color ramp visualization.
customColorRamp The custom gradient that Unity uses as a color ramp. If this is not specified, Unity uses Google Turbo color ramp.

描述

Draws a 3D texture using Slice rendering mode in 3D space.


Head scan rendered in slice mode with a custom gradient.

using UnityEditor;
using UnityEngine;

[ExecuteInEditMode] public class Reference : MonoBehaviour { public Texture3D texture; public Vector3 slicePositions; public FilterMode filterMode; public bool useColorRamp; public bool useCustomColorRamp;

// We should initialize this gradient before using it as a custom color ramp public Gradient customColorRampGradient; }

[CanEditMultipleObjects] [CustomEditor(typeof(Reference))] public class Handle : Editor { private void OnSceneViewGUI(SceneView sv) { Object[] objects = targets; foreach (var obj in objects) { Reference reference = obj as Reference; if (reference != null && reference.texture != null) { Handles.matrix = reference.transform.localToWorldMatrix; Handles.DrawTexture3DSlice(reference.texture, reference.slicePositions, reference.filterMode, reference.useColorRamp, reference.useCustomColorRamp ? reference.customColorRampGradient : null); } } }

void OnEnable() { SceneView.duringSceneGui += OnSceneViewGUI; }

void OnDisable() { SceneView.duringSceneGui -= OnSceneViewGUI; } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961