Peter Bay Bastian
7 年前
当前提交
f695b6fa
共有 16 个文件被更改,包括 63 次插入 和 300 次删除
-
3MaterialGraphProject/Assets/NewNodes/Editor/Keep/SamplerStateNode.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/UVNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/MatrixCommonNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
-
52MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/EnumControl.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/EnumControl.cs.meta
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/LevelsNodePresenter.cs.meta
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/MatrixCommonNodePresenter.cs.meta
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SwizzleNodePresenter.cs.meta
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/UVNodePresenter.cs.meta
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SamplerStateNodePresenter.cs.meta
-
41MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/LevelsNodePresenter.cs
-
46MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SwizzleNodePresenter.cs
-
49MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/MatrixCommonNodePresenter.cs
-
62MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SamplerStateNodePresenter.cs
-
38MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/UVNodePresenter.cs
|
|||
using System; |
|||
using System.Reflection; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.UIElements; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing.Controls |
|||
{ |
|||
[AttributeUsage(AttributeTargets.Property)] |
|||
public class EnumControlAttribute : Attribute, IControlAttribute |
|||
{ |
|||
string m_Label; |
|||
|
|||
public EnumControlAttribute(string label = null) |
|||
{ |
|||
m_Label = label; |
|||
} |
|||
|
|||
public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo) |
|||
{ |
|||
return new EnumControlView(m_Label, node, propertyInfo); |
|||
} |
|||
} |
|||
|
|||
public class EnumControlView : VisualElement |
|||
{ |
|||
GUIContent m_Label; |
|||
AbstractMaterialNode m_Node; |
|||
PropertyInfo m_PropertyInfo; |
|||
|
|||
public EnumControlView(string label, AbstractMaterialNode node, PropertyInfo propertyInfo) |
|||
{ |
|||
m_Node = node; |
|||
m_PropertyInfo = propertyInfo; |
|||
if (!propertyInfo.PropertyType.IsEnum) |
|||
throw new ArgumentException("Property must be an enum.", "propertyInfo"); |
|||
m_Label = new GUIContent(label ?? ObjectNames.NicifyVariableName(propertyInfo.Name)); |
|||
Add(new IMGUIContainer(OnGUIHandler)); |
|||
} |
|||
|
|||
void OnGUIHandler() |
|||
{ |
|||
var value = (Enum) m_PropertyInfo.GetValue(m_Node, null); |
|||
using (var changeCheckScope = new EditorGUI.ChangeCheckScope()) |
|||
{ |
|||
value = EditorGUILayout.EnumPopup(m_Label, value); |
|||
if (changeCheckScope.changed) |
|||
m_PropertyInfo.SetValue(m_Node, value, null); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3a1e13c5e67541d7ad7ae18ea5a834e4 |
|||
timeCreated: 1507817885 |
|
|||
fileFormatVersion: 2 |
|||
guid: 224a0b135d08f2c46a9486ae3e9fb082 |
|||
timeCreated: 1495457202 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: b7283eb87c37e4a43b5eddbf2d4360d1 |
|||
timeCreated: 1495448531 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 53bfb9e60f364eb44a4f0e0fc53f4325 |
|||
timeCreated: 1495474251 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: e043df2bbd87f654a99d3d5e89049abc |
|||
timeCreated: 1483884606 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 8ffcc48ccff1aea44b90acb362bc0dfc |
|||
timeCreated: 1495659152 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEditor.Experimental.UIElements.GraphView; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
class LevelsControlPresenter : GraphControlPresenter |
|||
{ |
|||
public override void OnGUIHandler() |
|||
{ |
|||
base.OnGUIHandler(); |
|||
|
|||
var tNode = node as LevelsNode; |
|||
if (tNode == null) |
|||
return; |
|||
|
|||
/*tNode.inputMin = EditorGUILayout.FloatField("InputMin:", tNode.inputMin); |
|||
tNode.inputMax = EditorGUILayout.FloatField("InputMax:", tNode.inputMax); |
|||
tNode.inputGamma = EditorGUILayout.FloatField("InputGamma:", tNode.inputGamma); |
|||
tNode.outputMin = EditorGUILayout.FloatField("OutputMin:", tNode.outputMin); |
|||
tNode.outputMax = EditorGUILayout.FloatField("OutputMax:", tNode.outputMax);*/ |
|||
} |
|||
|
|||
public override float GetHeight() |
|||
{ |
|||
return (EditorGUIUtility.singleLineHeight * 5 + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing; |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class LevelsNodePresenter : PropertyNodePresenter |
|||
{ |
|||
protected override IEnumerable<GraphControlPresenter> GetControlData() |
|||
{ |
|||
var instance = CreateInstance<LevelsControlPresenter>(); |
|||
instance.Initialize(node); |
|||
return new List<GraphControlPresenter>(base.GetControlData()) { instance }; |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEditor.Experimental.UIElements.GraphView; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
class SwizzleControlPresenter : GraphControlPresenter |
|||
{ |
|||
public override void OnGUIHandler() |
|||
{ |
|||
base.OnGUIHandler(); |
|||
|
|||
/*var tNode = node as SwizzleNode; |
|||
if (tNode == null) |
|||
return; |
|||
|
|||
SwizzleNode.SwizzleChannel[] newSwizzleChannels = (SwizzleNode.SwizzleChannel[])tNode.swizzleChannels.Clone(); |
|||
EditorGUI.BeginChangeCheck(); |
|||
newSwizzleChannels[0] = (SwizzleNode.SwizzleChannel)EditorGUILayout.EnumPopup("Red output:", newSwizzleChannels[0]); |
|||
newSwizzleChannels[1] = (SwizzleNode.SwizzleChannel)EditorGUILayout.EnumPopup("Green output:", newSwizzleChannels[1]); |
|||
newSwizzleChannels[2] = (SwizzleNode.SwizzleChannel)EditorGUILayout.EnumPopup("Blue output:", newSwizzleChannels[2]); |
|||
newSwizzleChannels[3] = (SwizzleNode.SwizzleChannel)EditorGUILayout.EnumPopup("Alpha output:", newSwizzleChannels[3]); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
tNode.swizzleChannels = newSwizzleChannels; |
|||
}*/ |
|||
} |
|||
|
|||
public override float GetHeight() |
|||
{ |
|||
return (EditorGUIUtility.singleLineHeight * 4 + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing; |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class SwizzleNodePresenter : PropertyNodePresenter |
|||
{ |
|||
protected override IEnumerable<GraphControlPresenter> GetControlData() |
|||
{ |
|||
var instance = CreateInstance<SwizzleControlPresenter>(); |
|||
instance.Initialize(node); |
|||
return new List<GraphControlPresenter>(base.GetControlData()) { instance }; |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.MaterialGraph; |
|||
using UnityEditor.Experimental.UIElements.GraphView; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
[Serializable] |
|||
class MatrixCommonContolPresenter : GraphControlPresenter |
|||
{ |
|||
private string[] m_MatrixTypeNames; |
|||
private string[] matrixTypeNames |
|||
{ |
|||
get |
|||
{ |
|||
if (m_MatrixTypeNames == null) |
|||
m_MatrixTypeNames = Enum.GetNames(typeof(CommonMatrixType)); |
|||
return m_MatrixTypeNames; |
|||
} |
|||
} |
|||
|
|||
public override void OnGUIHandler() |
|||
{ |
|||
base.OnGUIHandler(); |
|||
|
|||
var cNode = node as UnityEngine.MaterialGraph.MatrixCommonNode; |
|||
if (cNode == null) |
|||
return; |
|||
|
|||
cNode.matrix = (CommonMatrixType)EditorGUILayout.Popup((int)cNode.matrix, matrixTypeNames, EditorStyles.popup); |
|||
} |
|||
|
|||
public override float GetHeight() |
|||
{ |
|||
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class MatrixCommonNodePresenter : MaterialNodePresenter |
|||
{ |
|||
protected override IEnumerable<GraphControlPresenter> GetControlData() |
|||
{ |
|||
var instance = CreateInstance<MatrixCommonContolPresenter>(); |
|||
instance.Initialize(node); |
|||
return new List<GraphControlPresenter> { instance }; |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.MaterialGraph; |
|||
using UnityEditor.Experimental.UIElements.GraphView; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
[Serializable] |
|||
class SamplerStateControlPresenter : GraphControlPresenter |
|||
{ |
|||
private string[] samplerFilterMode; |
|||
private string[] samplerWrapMode; |
|||
|
|||
private string[] _samplerFilterMode |
|||
{ |
|||
get |
|||
{ |
|||
if (samplerFilterMode == null) |
|||
samplerFilterMode = Enum.GetNames(typeof(TextureSamplerState.FilterMode)); |
|||
return samplerFilterMode; |
|||
} |
|||
} |
|||
|
|||
private string[] _samplerWrapMode |
|||
{ |
|||
get |
|||
{ |
|||
if (samplerWrapMode == null) |
|||
samplerWrapMode = Enum.GetNames(typeof(TextureSamplerState.WrapMode)); |
|||
return samplerWrapMode; |
|||
} |
|||
} |
|||
|
|||
public override void OnGUIHandler() |
|||
{ |
|||
base.OnGUIHandler(); |
|||
|
|||
var cNode = node as SamplerStateNode; |
|||
if (cNode == null) |
|||
return; |
|||
|
|||
cNode.filter = (TextureSamplerState.FilterMode)EditorGUILayout.Popup((int)cNode.filter, _samplerFilterMode, EditorStyles.popup); |
|||
cNode.wrap = (TextureSamplerState.WrapMode)EditorGUILayout.Popup((int)cNode.wrap, _samplerWrapMode, EditorStyles.popup); |
|||
} |
|||
|
|||
public override float GetHeight() |
|||
{ |
|||
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class SamplerStateNodePresenter : MaterialNodePresenter |
|||
{ |
|||
protected override IEnumerable<GraphControlPresenter> GetControlData() |
|||
{ |
|||
var instance = CreateInstance<SamplerStateControlPresenter>(); |
|||
instance.Initialize(node); |
|||
return new List<GraphControlPresenter> { instance }; |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEditor.Experimental.UIElements.GraphView; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
[Serializable] |
|||
class UVNodeContolPresenter : GraphControlPresenter |
|||
{ |
|||
public override void OnGUIHandler() |
|||
{ |
|||
base.OnGUIHandler(); |
|||
|
|||
var cNode = node as UVNode; |
|||
if (cNode == null) |
|||
return; |
|||
|
|||
cNode.uvChannel = (UVChannel)EditorGUILayout.EnumPopup("Channel", cNode.uvChannel); |
|||
} |
|||
|
|||
public override float GetHeight() |
|||
{ |
|||
return EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing; |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class UVNodePresenter : MaterialNodePresenter |
|||
{ |
|||
protected override IEnumerable<GraphControlPresenter> GetControlData() |
|||
{ |
|||
var instance = CreateInstance<UVNodeContolPresenter>(); |
|||
instance.Initialize(node); |
|||
return new List<GraphControlPresenter> { instance }; |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue