您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
95 行
2.9 KiB
95 行
2.9 KiB
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEditor.Experimental.UIElements;
|
|
using UnityEngine;
|
|
using UnityEngine.Experimental.UIElements;
|
|
using UnityEditor.Graphing.Util;
|
|
using UnityEditor.ShaderGraph.Drawing.Controls;
|
|
|
|
namespace UnityEditor.ShaderGraph.Drawing
|
|
{
|
|
public class PBRSettingsView : VisualElement
|
|
{
|
|
PBRMasterNode m_Node;
|
|
public PBRSettingsView(PBRMasterNode node)
|
|
{
|
|
m_Node = node;
|
|
|
|
PropertySheet ps = new PropertySheet();
|
|
|
|
ps.Add(new PropertyRow(new Label("Workflow")), (row) =>
|
|
{
|
|
row.Add(new EnumField(PBRMasterNode.Model.Metallic), (field) =>
|
|
{
|
|
field.value = m_Node.model;
|
|
field.OnValueChanged(ChangeWorkFlow);
|
|
});
|
|
});
|
|
|
|
ps.Add(new PropertyRow(new Label("Surface")), (row) =>
|
|
{
|
|
row.Add(new EnumField(SurfaceType.Opaque), (field) =>
|
|
{
|
|
field.value = m_Node.surfaceType;
|
|
field.OnValueChanged(ChangeSurface);
|
|
});
|
|
});
|
|
|
|
ps.Add(new PropertyRow(new Label("Blend")), (row) =>
|
|
{
|
|
row.Add(new EnumField(AlphaMode.Additive), (field) =>
|
|
{
|
|
field.value = m_Node.alphaMode;
|
|
field.OnValueChanged(ChangeAlphaMode);
|
|
});
|
|
});
|
|
|
|
ps.Add(new PropertyRow(new Label("Two Sided")), (row) =>
|
|
{
|
|
row.Add(new Toggle(null), (toggle) =>
|
|
{
|
|
toggle.value = m_Node.twoSided.isOn;
|
|
toggle.OnToggle(ChangeTwoSided);
|
|
});
|
|
});
|
|
|
|
Add(ps);
|
|
}
|
|
|
|
void ChangeWorkFlow(ChangeEvent<Enum> evt)
|
|
{
|
|
if (Equals(m_Node.model, evt.newValue))
|
|
return;
|
|
|
|
m_Node.owner.owner.RegisterCompleteObjectUndo("Work Flow Change");
|
|
m_Node.model = (PBRMasterNode.Model)evt.newValue;
|
|
}
|
|
|
|
void ChangeSurface(ChangeEvent<Enum> evt)
|
|
{
|
|
if (Equals(m_Node.surfaceType, evt.newValue))
|
|
return;
|
|
|
|
m_Node.owner.owner.RegisterCompleteObjectUndo("Surface Change");
|
|
m_Node.surfaceType = (SurfaceType)evt.newValue;
|
|
}
|
|
|
|
void ChangeAlphaMode(ChangeEvent<Enum> evt)
|
|
{
|
|
if (Equals(m_Node.alphaMode, evt.newValue))
|
|
return;
|
|
|
|
m_Node.owner.owner.RegisterCompleteObjectUndo("Alpha Mode Change");
|
|
m_Node.alphaMode = (AlphaMode)evt.newValue;
|
|
}
|
|
|
|
void ChangeTwoSided()
|
|
{
|
|
m_Node.owner.owner.RegisterCompleteObjectUndo("Two Sided Change");
|
|
ToggleData td = m_Node.twoSided;
|
|
td.isOn ^= true;
|
|
m_Node.twoSided = td;
|
|
}
|
|
}
|
|
}
|