浏览代码

Added new settings files for the common settings on the master nodes, PBR and Unlit Master

/main
Martin Thorzen 7 年前
当前提交
2ff4fbd7
共有 9 个文件被更改,包括 230 次插入24 次删除
  1. 34
      com.unity.shadergraph/Editor/Data/MasterNodes/PBRMasterNode.cs
  2. 5
      com.unity.shadergraph/Editor/Data/MasterNodes/UnlitMasterNode.cs
  3. 3
      com.unity.shadergraph/Editor/Data/Nodes/IMasterNode.cs
  4. 8
      com.unity.shadergraph/Editor/Data/Nodes/MasterNode.cs
  5. 8
      com.unity.shadergraph/Editor/Drawing/Views/PropertySheet.cs
  6. 96
      com.unity.shadergraph/Editor/Drawing/Views/PBRSettingsView.cs
  7. 11
      com.unity.shadergraph/Editor/Drawing/Views/PBRSettingsView.cs.meta
  8. 78
      com.unity.shadergraph/Editor/Drawing/Views/UnlitSettingsView.cs
  9. 11
      com.unity.shadergraph/Editor/Drawing/Views/UnlitSettingsView.cs.meta

34
com.unity.shadergraph/Editor/Data/MasterNodes/PBRMasterNode.cs


[SerializeField]
SurfaceType m_SurfaceType;
[SerializeField]
bool m_SurfaceTypeHasValue;
public SurfaceType? surfaceType
[EnumControl("Surface")]
public SurfaceType surfaceType
get { return m_SurfaceTypeHasValue ? (SurfaceType?)m_SurfaceType : null; }
get { return m_SurfaceType; }
if (value.HasValue)
m_SurfaceType = value.Value;
m_SurfaceTypeHasValue = value.HasValue;
m_SurfaceType = value;
Dirty(ModificationScope.Graph);
}
}

[SerializeField]
bool m_AlphaModeHasValue;
public AlphaMode? alphaMode
[EnumControl("Blend")]
public AlphaMode alphaMode
get { return m_AlphaModeHasValue ? (AlphaMode?)m_AlphaMode : null; }
get { return m_AlphaMode; }
if (value.HasValue)
m_AlphaMode = value.Value;
m_AlphaModeHasValue = value.HasValue;
m_AlphaMode = value;
Dirty(ModificationScope.Graph);
}
}

List<ISlot> slots = new List<ISlot>();
GetSlots(slots);
return slots.OfType<IMayRequireNormal>().Aggregate(NeededCoordinateSpace.None, (mask, node) => mask | node.RequiresNormal());
}
protected override VisualElement CreateCommonSettingsElement()
{
return new PBRSettingsView(this);
//return null;
}
}
}

5
com.unity.shadergraph/Editor/Data/MasterNodes/UnlitMasterNode.cs


AlphaThresholdSlotId
});
}
protected override VisualElement CreateCommonSettingsElement()
{
return new UnlitSettingsView(this);
}
}
}

3
com.unity.shadergraph/Editor/Data/Nodes/IMasterNode.cs


using System.Collections.Generic;
using UnityEditor.Graphing;
public interface IMasterNode
public interface IMasterNode : INode
{
string GetShader(GenerationMode mode, string name, out List<PropertyCollector.TextureInfo> configuredTextures);
}

8
com.unity.shadergraph/Editor/Data/Nodes/MasterNode.cs


{
// do staff
var container = new VisualElement();
var commonSettingsElement = CreateCommonSettingsElement();
if (commonSettingsElement != null)
container.Add(commonSettingsElement);
foreach (var subShader in subShaders)
{
var settingsElement = subShader.CreateSettingsElement();

//return new MasterSettingsView(this);
return container;
}
protected virtual VisualElement CreateCommonSettingsElement()
{
return null;
}
}
}

8
com.unity.shadergraph/Editor/Drawing/Views/PropertySheet.cs


}
}
// public Label header
// {
// get { return m_Header; }
// set { m_Header = value; }
// }
public PropertySheet(Label header = null)
{
AddStyleSheetPath("Styles/PropertySheet");

m_HeaderContainer.Add(header);
// header.AddToClassList("header");
m_ContentContainer.Add(m_HeaderContainer);
shadow.Add(m_ContentContainer);
}

96
com.unity.shadergraph/Editor/Drawing/Views/PBRSettingsView.cs


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)
{
AddStyleSheetPath("Styles/PBRSettings");
m_Node = (PBRMasterNode)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;
}
}
}

11
com.unity.shadergraph/Editor/Drawing/Views/PBRSettingsView.cs.meta


fileFormatVersion: 2
guid: 0f6aa10456b30264a9bd4aeded39530a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

78
com.unity.shadergraph/Editor/Drawing/Views/UnlitSettingsView.cs


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 UnlitSettingsView : VisualElement
{
UnlitMasterNode m_Node;
public UnlitSettingsView(UnlitMasterNode node)
{
AddStyleSheetPath("Styles/UnlitSettings");
m_Node = (UnlitMasterNode)node;
PropertySheet ps = new PropertySheet();
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 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;
}
}
}

11
com.unity.shadergraph/Editor/Drawing/Views/UnlitSettingsView.cs.meta


fileFormatVersion: 2
guid: 66dcef8109abbfc4fa27499aaa708dd4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存