浏览代码

Updated the Settings UI.

/main
Martin Thorzen 7 年前
当前提交
bf9b4a4c
共有 9 个文件被更改,包括 105 次插入60 次删除
  1. 19
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs
  2. 23
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs
  3. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/NodeSettingsView.cs
  4. 50
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/PBRSettingsView.cs
  5. 25
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/NodeSettings.uss
  6. 22
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/PBRSettings.uss
  7. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/UXML/NodeSettings.uxml
  8. 15
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/UXML/PBRSettings.uxml
  9. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/UIUtilities.cs

19
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs


this.graph = graph;
MaterialGraph mg = (MaterialGraph)graph;
var node = mg.masterNode;
m_NodeSettingsView = new NodeSettingsView();
m_NodeSettingsView.visible = false;
Add(m_NodeSettingsView);
}
public AbstractMaterialGraph graph { get; private set; }

void SelectionChanged()
{
m_NodeSettingsView.Clear();
//if (selectedNodes.Count() == 1)
//{
// INode node = (INode)selectedNodes.First().userData;
// var settings = node as IHasSettings;
// if (settings != null)
// {
// m_NodeSettingsView.Add(settings.CreateSettingsElement());
// m_NodeSettingsView.visible = true;
// }
// else
// m_NodeSettingsView.visible = false;
//}
//else
// m_NodeSettingsView.visible = false;
}
public override void AddToSelection(ISelectable selectable)

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


VisualElement m_SettingsButton;
VisualElement m_SettingsDivider;
VisualElement m_Settings;
VisualElement m_NodeSettingsView;
public void Initialize(AbstractMaterialNode inNode, PreviewManager previewManager, IEdgeConnectorListener connectorListener)
{

VisualElement parent = collapseButton.parent;
parent.Add(buttonContainer);
m_NodeSettingsView = new NodeSettingsView();
m_NodeSettingsView.visible = false;
Add(m_NodeSettingsView);
m_SettingsContainer = new VisualElement { name = "settings-container" };
contents.Add(m_SettingsContainer);
if (node.hasPreview)
m_SettingsContainer.PlaceBehind(m_PreviewFiller);
{
{
UpdateSettingsExpandedState(settings);
}));
buttonContainer.Add(m_SettingsButton);

m_ShowSettings = !m_ShowSettings;
if (m_ShowSettings)
{
m_SettingsDivider = new VisualElement { name = "divider" };
m_SettingsDivider.AddToClassList("horizontal");
m_SettingsContainer.Add(m_SettingsDivider);
m_SettingsContainer.Add(m_Settings);
m_NodeSettingsView.Add(m_Settings);
m_NodeSettingsView.visible = true;
m_SettingsDivider.RemoveFromHierarchy();
m_NodeSettingsView.visible = false;
m_SettingsButton.RemoveFromClassList("clicked");
}
}

1
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/NodeSettingsView.cs


public NodeSettingsView()
{
AddStyleSheetPath("Styles/NodeSettings");
var uxml = Resources.Load<VisualTreeAsset>("UXML/NodeSettings");
uxml.CloneTree(this, null);
// Get the element we want to use as content container

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


using System.Linq;
using UnityEditor.Experimental.UIElements;
using UnityEditor.Graphing;
using UnityEditor.Graphing.Util;
using UnityEngine;
using UnityEngine.Experimental.UIElements;

{
VisualElement m_Container;
EnumField m_Model;
EnumField m_AlphaMode;
AddStyleSheetPath("Styles/PBRSettings");
var uxml = Resources.Load<VisualTreeAsset>("UXML/PBRSettings");
uxml.CloneTree(this, null);
m_Container = this.Q("container");
this.Add(new VisualElement { name = "container" }, (container) =>
{
container.Add(new VisualElement(), (row) =>
{
row.AddToClassList("row");
m_Model = new EnumField(m_Node.model);
m_AlphaMode = new EnumField(m_Node.alphaMode);
row.Add(new Label("Model"), (label) =>
{
label.AddToClassList("label");
});
m_Model.AddToClassList("enumcontainer");
m_AlphaMode.AddToClassList("enumcontainer");
row.Add(new EnumField(PBRMasterNode.Model.Metallic), (enumField) =>
{
enumField.value = m_Node.model;
enumField.OnValueChanged(ChangeModel);
enumField.AddToClassList("enumcontainer");
});
});
m_Container.Add(m_Model);
m_Container.Add(m_AlphaMode);
m_Model.OnValueChanged(ChangeModel);
m_AlphaMode.OnValueChanged(ChangeAlphaMode);
container.Add(new VisualElement(), (row) =>
{
row.AddToClassList("row");
row.Add(new Label("Alpha mode"), (label) =>
{
label.AddToClassList("label");
});
row.Add(new EnumField(AlphaMode.AdditiveBlend), (enumField) =>
{
enumField.value = m_Node.alphaMode;
enumField.OnValueChanged(ChangeAlphaMode);
enumField.AddToClassList("enumcontainer");
});
});
});
}
void ChangeModel(ChangeEvent<Enum> evt)

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


NodeSettingsView {
position-type: absolute;
position-left: 215;
position-top: 4;
}
/*width: 200;*/
width: 200;
/*background-color: #e8596e;
border-color: #e8596e;
background-color: rgba(0, 0, 0, 0.7);
border-color: #000000;
border-top-width: 5px;
border-right-width: 25px;
border-top-right-radius: 6px;*/
border-top-width: 1px;
border-bottom-width: 1px;
border-right-width: 1px;
border-left-width: 1px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
}
}

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


PBRSettingsView{
}
flex-grow: 1;
background-color: rgb(63, 63, 63);
background-color: rgba(0, 0, 0, 0.7);
}
PBRSettingsView > #container > .row {
flex-direction: row;
PBRSettingsView > #container > .enumcontainer{
PBRSettingsView > #container > .row > .label {
width: 75;
}
PBRSettingsView > #container > #rowContainer > #itemContainer{
flex-direction: column;
flex-grow: 1;
}
PBRSettingsView > #container > .row > .enumcontainer{
flex-grow: 1;
margin-left: 4;
margin-right: 4;
margin-top: 4;

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/UXML/NodeSettings.uxml


<UXML xmlns:ui="UnityEngine.Experimental.UIElements">
<ui:VisualElement name="mainContainer">
<Style path="Styles/NodeSettings"/>
<ui:Label name="title" text="Node Settings"/>
<ui:VisualElement name="contentContainer">
</ui:VisualElement>
</ui:VisualElement>

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


<UXML xmlns:ui="UnityEngine.Experimental.UIElements">
<UXML xmlns:ui="UnityEngine.Experimental.UIElements"
xmlns:sg="UnityEditor.ShaderGraph.Drawing">
<ui:VisualElement class="row" pickingMode="Ignore">
<!-- <ui:VisualElement name="itemContainer" pickingMode="Ignore" /> -->
<ui:Label class="label" name="typeLabel" text = "Plopp" pickingMode="Ignore" />
<ui:Label text="im an enum" pickingMode="Ignore" />
<ui:VisualElement name="itemContainer" pickingMode="Ignore" />
</ui:VisualElement>
<ui:VisualElement class="row" pickingMode="Ignore">
<!-- <ui:VisualElement name="itemContainer" pickingMode="Ignore" /> -->
<ui:Label class="label" name="typeLabel" text = "Plopp" pickingMode="Ignore" />
<sg:EnumElement />
<ui:VisualElement name="itemContainer" pickingMode="Ignore" />
</ui:VisualElement>
</ui:VisualElement>
</UXML>

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/UIUtilities.cs


using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.Graphing.Util
{

public static IEnumerable<T> ToEnumerable<T>(this T item)
{
yield return item;
}
public static void Add<T>(this VisualElement visualElement, T elementToAdd, Action<T> action)
where T : VisualElement
{
visualElement.Add(elementToAdd);
action(elementToAdd);
}
}
}
正在加载...
取消
保存