浏览代码

Forwardport pull request #336

/main
Peter Bay Bastian 7 年前
当前提交
6ec339e3
共有 18 个文件被更改,包括 48 次插入111 次删除
  1. 8
      com.unity.shadergraph/Editor/Drawing/Controls/ChannelEnumControl.cs
  2. 2
      com.unity.shadergraph/Editor/Drawing/Controls/ChannelEnumMaskControl.cs
  3. 4
      com.unity.shadergraph/Editor/Drawing/Controls/ChannelMixerControl.cs
  4. 2
      com.unity.shadergraph/Editor/Drawing/Controls/ColorControl.cs
  5. 2
      com.unity.shadergraph/Editor/Drawing/Controls/CubemapControl.cs
  6. 14
      com.unity.shadergraph/Editor/Drawing/Controls/DielectricSpecularControl.cs
  7. 2
      com.unity.shadergraph/Editor/Drawing/Controls/IntegerControl.cs
  8. 20
      com.unity.shadergraph/Editor/Drawing/Controls/SliderControl.cs
  9. 2
      com.unity.shadergraph/Editor/Drawing/Controls/TextureControl.cs
  10. 4
      com.unity.shadergraph/Editor/Drawing/Controls/ToggleControl.cs
  11. 8
      com.unity.shadergraph/Editor/Drawing/Controls/VectorControl.cs
  12. 2
      com.unity.shadergraph/Editor/Drawing/Inspector/MasterPreviewView.cs
  13. 14
      com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs
  14. 4
      com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs
  15. 2
      com.unity.shadergraph/Editor/Drawing/Views/Slots/MultiFloatSlotControlView.cs
  16. 7
      com.unity.shadergraph/Editor/Util/CompatibilityExtensions.cs
  17. 59
      com.unity.shadergraph/Editor/Drawing/Views/PixelCacheProfilerView.cs
  18. 3
      com.unity.shadergraph/Editor/Drawing/Views/PixelCacheProfilerView.cs.meta

8
com.unity.shadergraph/Editor/Drawing/Controls/ChannelEnumControl.cs


var value = (Enum)m_PropertyInfo.GetValue(m_Node, null);
m_ValueNames = Enum.GetNames(value.GetType());
CreatePopup();
}

if (scope == ModificationScope.Node)
{
CreatePopup();
m_PopupField.Dirty(ChangeType.Repaint);
}
m_PopupField.MarkDirtyRepaint();
}
}
void CreatePopup()

Remove(m_PopupField);
}
m_PreviousChannelCount = channelCount;
List<string> popupEntries = new List<string>();
for (int i = 0; i < channelCount; i++)

2
com.unity.shadergraph/Editor/Drawing/Controls/ChannelEnumMaskControl.cs


public void OnNodeModified(ModificationScope scope)
{
if (scope == ModificationScope.Graph)
m_Container.Dirty(ChangeType.Repaint);
m_Container.MarkDirtyRepaint();
}
private void UpdatePopup()

4
com.unity.shadergraph/Editor/Drawing/Controls/ChannelMixerControl.cs


buttonPanel.Add(outputButtonBlue);
Add(buttonPanel);
var redSliderPanel = new VisualElement { name = "sliderPanel" };
redSliderPanel.Add(new Label("R"));
Action<float> changedRedIn = (s) => { OnChangeSlider(s, 0); };

break;
}
m_PropertyInfo.SetValue(m_Node, m_ChannelMixer, null);
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
}
void OnClickButton(int outChannel)

2
com.unity.shadergraph/Editor/Drawing/Controls/ColorControl.cs


m_Node.owner.owner.RegisterCompleteObjectUndo("Color Change");
m_Color.color = evt.newValue;
m_PropertyInfo.SetValue(m_Node, m_Color, null);
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
}
void OnModeChanged(ChangeEvent<Enum> evt)

2
com.unity.shadergraph/Editor/Drawing/Controls/CubemapControl.cs


{
m_Node.owner.owner.RegisterCompleteObjectUndo("Cubemap Change");
m_PropertyInfo.SetValue(m_Node, evt.newValue, null);
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
}
}
}

14
com.unity.shadergraph/Editor/Drawing/Controls/DielectricSpecularControl.cs


m_PropertyInfo.SetValue(m_Node, m_DielectricMaterial, null);
if(m_RangeField != null)
m_RangeField.value = newValue;
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
}
void OnChangeIORSlider(float newValue)

m_PropertyInfo.SetValue(m_Node, m_DielectricMaterial, null);
if(m_IORField != null)
m_IORField.value = newValue;
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
}
FloatField AddField(VisualElement panel, Slider slider, int index, DielectricSpecularNode.DielectricMaterial initMaterial)

initValue = initMaterial.range;
var field = new FloatField { userData = index, value = initValue };
field.RegisterCallback<MouseDownEvent>(Repaint);
field.RegisterCallback<MouseMoveEvent>(Repaint);
field.OnValueChanged(evt =>

}
m_PropertyInfo.SetValue(m_Node, value, null);
m_UndoGroup = -1;
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
});
field.RegisterCallback<InputEvent>(evt =>
{

else
value.range = newValue;
m_PropertyInfo.SetValue(m_Node, value, null);
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
});
field.RegisterCallback<KeyDownEvent>(evt =>
{

RedrawRangeControls(value.range);
evt.StopPropagation();
}
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
});
panel.Add(field);
return field;

void Repaint<T>(MouseEventBase<T> evt) where T : MouseEventBase<T>, new()
{
evt.StopPropagation();
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
}
}
}

2
com.unity.shadergraph/Editor/Drawing/Controls/IntegerControl.cs


#endif
evt.newValue;
m_PropertyInfo.SetValue(m_Node, newValue, null);
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
}
}
}

20
com.unity.shadergraph/Editor/Drawing/Controls/SliderControl.cs


{
if (scope == ModificationScope.Graph)
{
Dirty(ChangeType.Repaint);
}
this.MarkDirtyRepaint();
}
}
void OnChangeSlider(float newValue)

m_PropertyInfo.SetValue(m_Node, value, null);
if(m_SliderInput != null)
m_SliderInput.value = newValue;
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
if(label != "")
{
var l = new Label(label);

}
field.RegisterCallback<MouseDownEvent>(Repaint);
field.RegisterCallback<MouseMoveEvent>(Repaint);
field.OnValueChanged(evt =>

m_PropertyInfo.SetValue(m_Node, value, null);
m_UndoGroup = -1;
UpdateSlider(m_SliderPanel, index, value);
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
});
field.RegisterCallback<InputEvent>(evt =>
{

var value = (Vector3)m_PropertyInfo.GetValue(m_Node, null);
value[index] = newValue;
m_PropertyInfo.SetValue(m_Node, value, null);
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
});
field.RegisterCallback<KeyDownEvent>(evt =>
{

UpdateSlider(m_SliderPanel, index, m_Value);
evt.StopPropagation();
}
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
});
panel.Add(field);
return field;

void Repaint<T>(MouseEventBase<T> evt) where T : MouseEventBase<T>, new()
{
evt.StopPropagation();
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
}
}
}

2
com.unity.shadergraph/Editor/Drawing/Controls/TextureControl.cs


{
m_Node.owner.owner.RegisterCompleteObjectUndo("Texture Change");
m_PropertyInfo.SetValue(m_Node, evt.newValue, null);
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
}
}
}

4
com.unity.shadergraph/Editor/Drawing/Controls/ToggleControl.cs


if (scope == ModificationScope.Graph)
{
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
}
}

var value = (Toggle)m_PropertyInfo.GetValue(m_Node, null);
value.isOn = !value.isOn;
m_PropertyInfo.SetValue(m_Node, value, null);
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
}
}
}

8
com.unity.shadergraph/Editor/Drawing/Controls/VectorControl.cs


value[index] = (float)evt.newValue;
SetValue(value);
m_UndoGroup = -1;
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
});
field.RegisterCallback<InputEvent>(evt =>
{

var value = GetValue();
value[index] = newValue;
SetValue(value);
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
});
field.RegisterCallback<KeyDownEvent>(evt =>
{

m_Value = GetValue();
evt.StopPropagation();
}
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
});
Add(field);
}

void Repaint<T>(MouseEventBase<T> evt) where T : MouseEventBase<T>, new()
{
evt.StopPropagation();
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
}
}
}

2
com.unity.shadergraph/Editor/Drawing/Inspector/MasterPreviewView.cs


void OnPreviewChanged()
{
m_PreviewTextureView.image = StyleValue<Texture>.Create(m_PreviewRenderHandle.texture ?? Texture2D.blackTexture);
m_PreviewTextureView.Dirty(ChangeType.Repaint);
m_PreviewTextureView.MarkDirtyRepaint();
}
void ChangePrimitiveMesh(string primitiveName)

14
com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs


m_GraphView.RegisterCallback<KeyDownEvent>(OnSpaceDown);
content.Add(m_GraphView);
// Uncomment to enable pixel caching profiler
// m_ProfilerView = new PixelCacheProfilerView(this);
// m_GraphView.Add(m_ProfilerView);
m_BlackboardProvider = new BlackboardProvider(assetName, graph);
m_GraphView.Add(m_BlackboardProvider.blackboard);
Rect blackboardLayout = m_BlackboardProvider.blackboard.layout;

node.UpdatePortInputVisibilities();
UpdateEdgeColors(nodesToUpdate);
if (m_ProfilerView != null)
m_ProfilerView.Profile();
}
void AddNode(INode node)

nodeView.Initialize(node as AbstractMaterialNode, m_PreviewManager, m_EdgeConnectorListener);
node.RegisterCallback(OnNodeChanged);
nodeView.Dirty(ChangeType.Repaint);
nodeView.MarkDirtyRepaint();
if (m_SearchWindowProvider.nodeNeedsRepositioning && m_SearchWindowProvider.targetSlotReference.nodeGuid.Equals(node.guid))
{

var drawState = nodeView.node.drawState;
drawState.position = position;
nodeView.node.drawState = drawState;
nodeView.Dirty(ChangeType.Repaint);
port.Dirty(ChangeType.Repaint);
nodeView.MarkDirtyRepaint();
port.MarkDirtyRepaint();
}
Edge AddEdge(IEdge edge)

}
Stack<MaterialNodeView> m_NodeStack = new Stack<MaterialNodeView>();
PixelCacheProfilerView m_ProfilerView;
void UpdateEdgeColors(HashSet<MaterialNodeView> nodeViews)
{

4
com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs


var oldVisibility = portInputView.visible;
portInputView.visible = expanded && !node.owner.GetEdges(node.GetSlotReference(slot.id)).Any();
if (portInputView.visible != oldVisibility)
m_PortInputContainer.Dirty(ChangeType.Repaint);
m_PortInputContainer.MarkDirtyRepaint();
}
}

if (m_PreviewImage.image != m_PreviewRenderData.texture)
m_PreviewImage.image = m_PreviewRenderData.texture;
else
m_PreviewImage.Dirty(ChangeType.Repaint);
m_PreviewImage.MarkDirtyRepaint();
}
}

2
com.unity.shadergraph/Editor/Drawing/Views/Slots/MultiFloatSlotControlView.cs


m_UndoGroup = -1;
evt.StopPropagation();
}
Dirty(ChangeType.Repaint);
this.MarkDirtyRepaint();
});
Add(field);
}

7
com.unity.shadergraph/Editor/Util/CompatibilityExtensions.cs


toggle.value = value;
#endif
}
#if !UNITY_2018_3_OR_NEWER
public static void MarkDirtyRepaint(this VisualElement element)
{
element.Dirty(ChangeType.Repaint);
}
#endif
}
}

59
com.unity.shadergraph/Editor/Drawing/Views/PixelCacheProfilerView.cs


using System.Linq;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph.Drawing
{
public class PixelCacheProfilerView : VisualElement
{
readonly VisualElement m_Target;
Label m_TotalLabel;
Label m_DirtyLabel;
Label m_TotalNodeContentsLabel;
Label m_DirtyNodeContentsLabel;
Label m_TotalPreviewsLabel;
Label m_DirtyPreviewsLabel;
Label m_TotalInlinesLabel;
Label m_DirtyInlinesLabel;
public PixelCacheProfilerView(VisualElement target)
{
m_Target = target;
var tpl = Resources.Load<VisualTreeAsset>("UXML/PixelCacheProfiler");
tpl.CloneTree(this, null);
m_TotalLabel = this.Q<Label>("totalLabel");
m_DirtyLabel = this.Q<Label>("dirtyLabel");
m_TotalNodeContentsLabel = this.Q<Label>("totalNodeContentsLabel");
m_DirtyNodeContentsLabel = this.Q<Label>("dirtyNodeContentsLabel");
m_TotalPreviewsLabel = this.Q<Label>("totalPreviewsLabel");
m_DirtyPreviewsLabel = this.Q<Label>("dirtyPreviewsLabel");
m_TotalInlinesLabel = this.Q<Label>("totalInlinesLabel");
m_DirtyInlinesLabel = this.Q<Label>("dirtyInlinesLabel");
}
public void Profile()
{
var caches = m_Target.Query().Where(ve => ve.clippingOptions == ClippingOptions.ClipAndCacheContents).Build().ToList();
var dirtyCaches = caches.Where(ve => ve.IsDirty(ChangeType.Repaint)).ToList();
m_TotalLabel.text = caches.Count.ToString();
m_DirtyLabel.text = dirtyCaches.Count.ToString();
var nodeContentsCaches = caches.Where(ve => ve.name == "node-border").ToList();
var dirtyNodeContentsCaches = nodeContentsCaches.Where(ve => ve.IsDirty(ChangeType.Repaint)).ToList();
m_TotalNodeContentsLabel.text = nodeContentsCaches.Count.ToString();
m_DirtyNodeContentsLabel.text = dirtyNodeContentsCaches.Count.ToString();
var previewCaches = caches.Where(ve => ve.name == "previewContainer").ToList();
var dirtyPreviewCaches = previewCaches.Where(ve => ve.IsDirty(ChangeType.Repaint)).ToList();
m_TotalPreviewsLabel.text = previewCaches.Count.ToString();
m_DirtyPreviewsLabel.text = dirtyPreviewCaches.Count.ToString();
var inlineCaches = caches.Where(ve => ve.name == "portInputContainer").ToList();
var dirtyInlineCaches = inlineCaches.Where(ve => ve.IsDirty(ChangeType.Repaint)).ToList();
m_TotalInlinesLabel.text = inlineCaches.Count.ToString();
m_DirtyInlinesLabel.text = dirtyInlineCaches.Count.ToString();
}
}
}

3
com.unity.shadergraph/Editor/Drawing/Views/PixelCacheProfilerView.cs.meta


fileFormatVersion: 2
guid: 7147f25b12dd4427b4c8afd44624f35b
timeCreated: 1517227822
正在加载...
取消
保存