浏览代码

Added a Settings Menu for Nodes.

/main
Martin Thorzen 7 年前
当前提交
e1d9b584
共有 21 个文件被更改,包括 562 次插入30 次删除
  1. 14
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/MasterNodes/UnlitMasterNode.cs
  2. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs
  3. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/PBRSettingsView.cs
  4. 17
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialNodeView.uss
  5. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/NodeSettings.uss
  6. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/PBRSettings.uss
  7. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/UXML/PBRSettings.uxml
  8. 43
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/UnlitSettingsView.cs
  9. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/UnlitSettingsView.cs.meta
  10. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Icons/SettingsIcons.png
  11. 105
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Icons/SettingsIcons.png.meta
  12. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Icons/SettingsIcons@2x.png
  13. 105
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Icons/SettingsIcons@2x.png.meta
  14. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Icons/SettingsIcons_hover.png
  15. 105
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Icons/SettingsIcons_hover.png.meta
  16. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Icons/SettingsIcons_hover@2x.png
  17. 105
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Icons/SettingsIcons_hover@2x.png.meta
  18. 16
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/UnlitSettings.uss
  19. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/UnlitSettings.uss.meta
  20. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/UXML/UnlitSettings.uxml
  21. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/UXML/UnlitSettings.uxml.meta

14
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/MasterNodes/UnlitMasterNode.cs


using System.Collections.Generic;
using System.Linq;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing;
using UnityEditor.ShaderGraph.Drawing.Controls;
using UnityEngine;
using UnityEngine.Experimental.UIElements;

[SerializeField]
private AlphaMode m_AlphaMode;
[EnumControl("")]
//[EnumControl("")]
public AlphaMode alphaMode
{
get { return m_AlphaMode; }

public VisualElement CreateSettingsElement()
{
VisualElement rowView = new VisualElement();
rowView.AddToClassList("row");
Label label = new Label("Unlit");
label.AddToClassList("rowLabel");
rowView.Add(label);
return rowView;
return new UnlitSettingsView(this);
}
}
}

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs


parent.Add(buttonContainer);
//m_SettingsContainer.SendToBack();
var settings = node as IHasSettings;
if (settings != null)
{

m_SettingsContainer.PlaceBehind(m_PreviewFiller);
m_SettingsButton = new VisualElement {name = "settings-button"};
m_SettingsButton.Add(new VisualElement { name = "icon" });

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/PBRSettingsView.cs


m_Container.Add(m_Model);
m_Container.Add(m_AlphaMode);
m_Model.OnValueChanged(ChangeModel);
m_AlphaMode.OnValueChanged(ChangeAlphaMode);
}

17
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialNodeView.uss


}
MaterialNodeView > #settings-container {
background-color : rgb(245, 155, 225);
background-color : rgb(63, 63, 63);
}
MaterialNodeView > #node-border > #title > #button-container{

MaterialNodeView > #node-border > #title > #button-container > #settings-button{
align-self : center;
width : 16;
width : 12;
background-color: #2B2B2B;
background-color: #2B2B2B;
background-image : resource("Icons/SettingsIcons_hover");
width : 12;
height : 12;
background-color: #2B2B2B;
/*background-color: #2B2B2B;*/
background-image : resource("Icons/settingsbutton");
width : 16;
height : 16;
background-image : resource("Icons/SettingsIcons");
width : 12;
height : 12;
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/NodeSettings.uss


NodeSettingsView > #mainContainer {
/*width: 200;*/
/*background-color: #e8596e;*/
/*background-color: #e8596e;
border-top-right-radius: 6px;
border-top-right-radius: 6px;*/
}
NodeSettingsView > #mainContainer > #title {

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/PBRSettings.uss


PBRSettingsView > #container{
background-color: rgb(167, 142, 142);
padding-top: 4;
padding-left: 4;
padding-right: 4;
padding-bottom: 4;
background-color: rgb(63, 63, 63);
text-color: rgb(155, 245, 245);
margin-left: 4;
margin-right: 4;
margin-top: 4;
margin-bottom: 4;
text-color: rgb(193, 193, 193);
}

1
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/UXML/PBRSettings.uxml


<UXML xmlns:ui="UnityEngine.Experimental.UIElements">
<ui:VisualElement name="container">
<Style path="Styles/PBRSettings"/>
<!-->ui:Label name="nodename" text="Settings"/-->
</ui:VisualElement>
</UXML>

43
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/UnlitSettingsView.cs


using System;
using System.Linq;
using UnityEditor.Experimental.UIElements;
using UnityEditor.Graphing;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph.Drawing
{
public class UnlitSettingsView : VisualElement
{
VisualElement m_Container;
EnumField m_AlphaMode;
UnlitMasterNode m_Node;
public UnlitSettingsView(INode node)
{
m_Node = (UnlitMasterNode)node;
var uxml = Resources.Load<VisualTreeAsset>("UXML/UnlitSettings");
uxml.CloneTree(this, null);
m_Container = this.Q("container");
m_AlphaMode = new EnumField(m_Node.alphaMode);
m_AlphaMode.AddToClassList("enumcontainer");
m_Container.Add(m_AlphaMode);
m_AlphaMode.OnValueChanged(ChangeAlphaMode);
}
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;
}
}
}

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/UnlitSettingsView.cs.meta


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

5
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Icons/SettingsIcons.png

之前 之后
宽度: 12  |  高度: 12  |  大小: 407 B

105
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Icons/SettingsIcons.png.meta


fileFormatVersion: 2
guid: 53bf71ace226b574d88c828e8b631aae
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 5
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: iPhone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Icons/SettingsIcons@2x.png

之前 之后
宽度: 24  |  高度: 24  |  大小: 868 B

105
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Icons/SettingsIcons@2x.png.meta


fileFormatVersion: 2
guid: 66e0f20149bec7a4eaee2f2d8aec158a
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 5
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: iPhone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Icons/SettingsIcons_hover.png

之前 之后
宽度: 12  |  高度: 12  |  大小: 380 B

105
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Icons/SettingsIcons_hover.png.meta


fileFormatVersion: 2
guid: 6bfd5f3c15e1ee7498657be747544985
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 5
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: iPhone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Icons/SettingsIcons_hover@2x.png

之前 之后
宽度: 24  |  高度: 24  |  大小: 808 B

105
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Icons/SettingsIcons_hover@2x.png.meta


fileFormatVersion: 2
guid: b1b079d053c3d0c41952dadf32a89ffd
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 5
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: iPhone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

16
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/UnlitSettings.uss


UnlitSettingsView > #container{
padding-top: 4;
padding-left: 4;
padding-right: 4;
padding-bottom: 4;
background-color: rgb(63, 63, 63);
}
UnlitSettingsView > #container > .enumcontainer{
margin-left: 4;
margin-right: 4;
margin-top: 4;
margin-bottom: 4;
text-color: rgb(193, 193, 193);
}

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/UnlitSettings.uss.meta


fileFormatVersion: 2
guid: 9d3e4b37febc07345bbfa4c4ee432c67
ScriptedImporter:
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}

5
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/UXML/UnlitSettings.uxml


<UXML xmlns:ui="UnityEngine.Experimental.UIElements">
<ui:VisualElement name="container">
<Style path="Styles/UnlitSettings"/>
</ui:VisualElement>
</UXML>

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/UXML/UnlitSettings.uxml.meta


fileFormatVersion: 2
guid: 62180873ad7c1fb4989e7158b0805f32
ScriptedImporter:
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
正在加载...
取消
保存