Boat Attack使用了Universal RP的许多新图形功能,可以用于探索 Universal RP 的使用方式和技巧。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

76 行
3.4 KiB

using UnityEngine;
using UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
[VolumeComponentEditor(typeof(ChannelMixer))]
sealed class ChannelMixerEditor : VolumeComponentEditor
{
SerializedDataParameter m_RedOutRedIn;
SerializedDataParameter m_RedOutGreenIn;
SerializedDataParameter m_RedOutBlueIn;
SerializedDataParameter m_GreenOutRedIn;
SerializedDataParameter m_GreenOutGreenIn;
SerializedDataParameter m_GreenOutBlueIn;
SerializedDataParameter m_BlueOutRedIn;
SerializedDataParameter m_BlueOutGreenIn;
SerializedDataParameter m_BlueOutBlueIn;
SavedInt m_SelectedChannel;
public override void OnEnable()
{
var o = new PropertyFetcher<ChannelMixer>(serializedObject);
m_RedOutRedIn = Unpack(o.Find(x => x.redOutRedIn));
m_RedOutGreenIn = Unpack(o.Find(x => x.redOutGreenIn));
m_RedOutBlueIn = Unpack(o.Find(x => x.redOutBlueIn));
m_GreenOutRedIn = Unpack(o.Find(x => x.greenOutRedIn));
m_GreenOutGreenIn = Unpack(o.Find(x => x.greenOutGreenIn));
m_GreenOutBlueIn = Unpack(o.Find(x => x.greenOutBlueIn));
m_BlueOutRedIn = Unpack(o.Find(x => x.blueOutRedIn));
m_BlueOutGreenIn = Unpack(o.Find(x => x.blueOutGreenIn));
m_BlueOutBlueIn = Unpack(o.Find(x => x.blueOutBlueIn));
m_SelectedChannel = new SavedInt($"{target.GetType()}.SelectedChannel", 0);
}
public override void OnInspectorGUI()
{
int currentChannel = m_SelectedChannel.value;
EditorGUI.BeginChangeCheck();
{
using (new EditorGUILayout.HorizontalScope())
{
if (GUILayout.Toggle(currentChannel == 0, EditorGUIUtility.TrTextContent("Red", "Red output channel."), EditorStyles.miniButtonLeft)) currentChannel = 0;
if (GUILayout.Toggle(currentChannel == 1, EditorGUIUtility.TrTextContent("Green", "Green output channel."), EditorStyles.miniButtonMid)) currentChannel = 1;
if (GUILayout.Toggle(currentChannel == 2, EditorGUIUtility.TrTextContent("Blue", "Blue output channel."), EditorStyles.miniButtonRight)) currentChannel = 2;
}
}
if (EditorGUI.EndChangeCheck())
GUI.FocusControl(null);
m_SelectedChannel.value = currentChannel;
if (currentChannel == 0)
{
PropertyField(m_RedOutRedIn, EditorGUIUtility.TrTextContent("Red"));
PropertyField(m_RedOutGreenIn, EditorGUIUtility.TrTextContent("Green"));
PropertyField(m_RedOutBlueIn, EditorGUIUtility.TrTextContent("Blue"));
}
else if (currentChannel == 1)
{
PropertyField(m_GreenOutRedIn, EditorGUIUtility.TrTextContent("Red"));
PropertyField(m_GreenOutGreenIn, EditorGUIUtility.TrTextContent("Green"));
PropertyField(m_GreenOutBlueIn, EditorGUIUtility.TrTextContent("Blue"));
}
else
{
PropertyField(m_BlueOutRedIn, EditorGUIUtility.TrTextContent("Red"));
PropertyField(m_BlueOutGreenIn, EditorGUIUtility.TrTextContent("Green"));
PropertyField(m_BlueOutBlueIn, EditorGUIUtility.TrTextContent("Blue"));
}
}
}
}