Fix all warnings
using UnityEditor.Graphing;
using System.Linq;
using System.Collections;
namespace UnityEditor.ShaderGraph
{
/* [Title("Art", "ChannelBlend")]
/* [Title("Math", "Advanced", "Adder")]
using System;
using System.Reflection;
using UnityEngine;
/*namespace UnityEditor.ShaderGraph
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEditor;
using Activator = System.Activator;
using Array = System.Array;
using Type = System.Type;
[System.Serializable]
/* [Title("UV", "Tri-Planar Mapping")]
/* [Title("Procedural", "Scatter")]
/* [Title("Input", "Toggle")]
using UnityEditor.ShaderGraph.Drawing.Controls;
using System.Text;
using System.IO;
using UnityEditor.ProjectWindowCallback;
using UnityEditor.ShaderGraph;
}
namespace UnityEditor.Graphing
using System;
using System.Reflection;
[Title("Artistic", "Filter", "Dither")]
using UnityEditor.ShaderGraph.Drawing.Slots;
using UnityEngine.Experimental.UIElements;
using System.Linq.Expressions;
using Object = System.Object;
if (dropTarget == null || !dropTarget.CanAcceptDrop(selection))
return;
var propagation = EventPropagation.Continue;
propagation = dropTarget.DragUpdated(evt, selection, dropTarget);
dropTarget.DragUpdated(evt, selection, dropTarget);
propagation = dropTarget.DragPerform(evt, selection, dropTarget);
dropTarget.DragPerform(evt, selection, dropTarget);
propagation = dropTarget.DragExited();
dropTarget.DragExited();
// if (propagation == EventPropagation.Stop)
// evt.StopPropagation();
class BlackboardProvider
readonly string m_AssetName;
readonly AbstractMaterialGraph m_Graph;
readonly Texture2D m_ExposedIcon;
readonly Dictionary<Guid, BlackboardRow> m_PropertyRows;
public BlackboardProvider(string assetName, AbstractMaterialGraph graph)
m_AssetName = assetName;
m_Graph = graph;
m_ExposedIcon = Resources.Load("GraphView/Nodes/BlackboardFieldExposed") as Texture2D;
m_PropertyRows = new Dictionary<Guid, BlackboardRow>();
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEditor.Experimental.UIElements;
using UnityEngine.Experimental.UIElements.StyleSheets;
namespace UnityEditor.ShaderGraph.Drawing.Controls
using Color = UnityEditor.ShaderGraph.ColorNode.Color;
public class SliderControlView : VisualElement, INodeModificationListener
GUIContent m_Label;
AbstractMaterialNode m_Node;
PropertyInfo m_PropertyInfo;
bool m_DisplayMinMax;
VisualElement m_SliderPanel;
Slider m_Slider;
FloatField m_SliderInput;
FloatField m_MinField;
FloatField m_MaxField;
public SliderControlView(string label, bool displayMinMax, AbstractMaterialNode node, PropertyInfo propertyInfo)
if (propertyInfo.PropertyType != typeof(Vector3))
throw new ArgumentException("Property must be of type Vector3.", "propertyInfo");
m_Label = new GUIContent(label ?? ObjectNames.NicifyVariableName(propertyInfo.Name));
new GUIContent(label ?? ObjectNames.NicifyVariableName(propertyInfo.Name));
m_Value = (Vector3)m_PropertyInfo.GetValue(m_Node, null);
m_SliderPanel = new VisualElement { name = "SliderPanel" };
if(m_DisplayMinMax)
var fieldsPanel = new VisualElement { name = "FieldsPanel" };
m_MinField = AddField(fieldsPanel, "Min", 1, m_Value);
m_MaxField = AddField(fieldsPanel, "Max", 2, m_Value);
AddField(fieldsPanel, "Min", 1, m_Value);
AddField(fieldsPanel, "Max", 2, m_Value);
Add(fieldsPanel);
using Object = UnityEngine.Object;
namespace UnityEditor.ShaderGraph.Drawing.Inspector
PreviewManager m_PreviewManager;
PreviewTextureView m_PreviewTextureView;
Image m_PreviewTextureView;
Vector2 m_PreviewScrollPosition;
ObjectField m_PreviewMeshPicker;
public MasterPreviewView(string assetName, PreviewManager previewManager, AbstractMaterialGraph graph)
this.clippingOptions = ClippingOptions.ClipAndCacheContents;
m_PreviewManager = previewManager;
m_PreviewRenderHandle.onPreviewChanged += OnPreviewChanged;
var topContainer = new VisualElement() { name = "top" };
var middleContainer = new VisualElement {name = "middle"};
m_PreviewTextureView = new PreviewTextureView { name = "preview", image = Texture2D.blackTexture };
m_PreviewTextureView.AddManipulator(new Draggable(OnMouseDragPreviewMesh, true));
m_PreviewTextureView.AddManipulator((IManipulator)Activator.CreateInstance(s_ContextualMenuManipulator, (Action<ContextualMenuPopulateEvent>)BuildContextualMenu));
middleContainer.Add(m_PreviewTextureView);
m_PreviewTextureView = CreatePreview(Texture2D.blackTexture);
Image CreatePreview(Texture texture)
var image = new Image { name = "preview", image = StyleValue<Texture>.Create(m_PreviewRenderHandle.texture ?? texture) };
image.AddManipulator(new Draggable(OnMouseDragPreviewMesh, true));
image.AddManipulator((IManipulator)Activator.CreateInstance(s_ContextualMenuManipulator, (Action<ContextualMenuPopulateEvent>)BuildContextualMenu));
return image;
void BuildContextualMenu(ContextualMenuPopulateEvent evt)
foreach (var primitiveTypeName in Enum.GetNames(typeof(PrimitiveType)))
void OnPreviewChanged()
m_PreviewTextureView.image = m_PreviewRenderHandle.texture ?? Texture2D.blackTexture;
m_PreviewTextureView.image = StyleValue<Texture>.Create(m_PreviewRenderHandle.texture ?? Texture2D.blackTexture);
m_PreviewTextureView.Dirty(ChangeType.Repaint);
public void RefreshRenderTextureSize()
RenderTextureDescriptor descriptor = m_PreviewRenderHandle.renderTexture.descriptor;
var currentWidth = m_PreviewRenderHandle.texture != null ? m_PreviewRenderHandle.texture.width : -1;
var currentHeight = m_PreviewRenderHandle.texture != null ? m_PreviewRenderHandle.texture.height : -1;
if (Mathf.Approximately(descriptor.width, targetHeight) && Mathf.Approximately(descriptor.height, targetWidth))
if (Mathf.Approximately(currentWidth, targetHeight) && Mathf.Approximately(currentHeight, targetWidth))
descriptor.width = (int)m_PreviewTextureView.contentRect.width;
descriptor.height = (int)m_PreviewTextureView.contentRect.height;
m_PreviewRenderHandle.renderTexture.Release();
Object.DestroyImmediate(m_PreviewRenderHandle.renderTexture);
m_PreviewRenderHandle.renderTexture = new RenderTexture(descriptor) { hideFlags = HideFlags.HideAndDontSave };
DirtyMasterNode(ModificationScope.Node);
m_PreviewManager.ResizeMasterPreview(m_PreviewTextureView.contentRect.size);
public void UpdateRenderTextureOnNextLayoutChange()
using UnityEditor.MemoryProfiler;
using System.Xml;
using UnityEngine.EventSystems;
namespace UnityEditor.ShaderGraph.Drawing
using System.Collections;
using UnityEngine;
using System;
using UnityEngine.Assertions;
using Edge = UnityEditor.Experimental.UIElements.GraphView.Edge;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
Texture2D m_ErrorTexture;
Shader m_UberShader;
string m_OutputIdName;
Vector2? m_NewMasterPreviewSize;
public PreviewRenderData masterRenderData
renderTexture = new RenderTexture(400, 400, 16, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default) { hideFlags = HideFlags.HideAndDontSave }
};
m_MasterRenderData.renderTexture.Create();
public void ResizeMasterPreview(Vector2 newSize)
m_NewMasterPreviewSize = newSize;
m_DirtyPreviews.Add(masterRenderData.shaderData.node.tempId.index);
public PreviewRenderData GetPreview(AbstractMaterialNode node)
return m_RenderDatas[node.tempId.index];
shaderData = shaderData,
renderTexture = new RenderTexture(200, 200, 16, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default) { hideFlags = HideFlags.HideAndDontSave }
renderData.renderTexture.Create();
Set(m_Identifiers, node.tempId, node.tempId);
Set(m_RenderDatas, node.tempId, renderData);
m_DirtyShaders.Add(node.tempId.index);
var renderMasterPreview = masterRenderData.shaderData != null && m_DirtyPreviews.Contains(masterRenderData.shaderData.node.tempId.index);
if (renderMasterPreview)
if (m_NewMasterPreviewSize.HasValue)
if (masterRenderData.renderTexture != null)
Object.DestroyImmediate(masterRenderData.renderTexture, true);
masterRenderData.renderTexture = new RenderTexture((int)m_NewMasterPreviewSize.Value.x, (int)m_NewMasterPreviewSize.Value.y, 16, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default) { hideFlags = HideFlags.HideAndDontSave };
masterRenderData.renderTexture.Create();
masterRenderData.texture = masterRenderData.renderTexture;
m_NewMasterPreviewSize = null;
var mesh = m_Graph.previewData.serializedMesh.mesh ? m_Graph.previewData.serializedMesh.mesh : m_SceneResources.sphere;
var previewTransform = Matrix4x4.Rotate(m_Graph.previewData.rotation);
var scale = m_Graph.previewData.scale;
public WindowDockingLayout previewLayout = new WindowDockingLayout();
public WindowDockingLayout blackboardLayout = new WindowDockingLayout();
[NonSerialized]
public WindowDockingLayout defaultPreviewLayout = new WindowDockingLayout();
public WindowDockingLayout defaultBlackboardLayout = new WindowDockingLayout();
public Vector2 masterPreviewSize = new Vector2(400, 400);
public class GraphEditorView : VisualElement, IDisposable
EdgeConnectorListener m_EdgeConnectorListener;
BlackboardProvider m_BlackboardProvider;
string m_FloatingWindowsLayoutKey;
const string k_FloatingWindowsLayoutKey = "UnityEditor.ShaderGraph.FloatingWindowsLayout";
FloatingWindowsLayout m_FloatingWindowsLayout;
public Action saveRequested { get; set; }
AddStyleSheetPath("Styles/GraphEditorView");
m_EditorWindow = editorWindow;
previewManager = new PreviewManager(graph);
string serializedWindowLayout = EditorUserSettings.GetConfigValue(k_FloatingWindowsLayoutKey);
if (!string.IsNullOrEmpty(serializedWindowLayout))
m_FloatingWindowsLayout = JsonUtility.FromJson<FloatingWindowsLayout>(serializedWindowLayout);
if (m_FloatingWindowsLayout.masterPreviewSize.x > 0f && m_FloatingWindowsLayout.masterPreviewSize.y > 0f)
previewManager.ResizeMasterPreview(m_FloatingWindowsLayout.masterPreviewSize);
previewManager.RenderPreviews();
var toolbar = new IMGUIContainer(() =>
if (showInProjectRequested != null)
showInProjectRequested();
GUILayout.Space(6);
if (GUILayout.Button("Reset Layout", EditorStyles.toolbarButton))
m_MasterPreviewView.layout = m_FloatingWindowsLayout.defaultPreviewLayout.GetLayout(layout);
m_BlackboardProvider.blackboard.layout = m_FloatingWindowsLayout.defaultBlackboardLayout.GetLayout(layout);
m_MasterPreviewView.UpdateRenderTextureOnNextLayoutChange();
UpdateSerializedWindowLayout();
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
UnregisterCallback<PostLayoutEvent>(ApplySerializewindowLayouts);
m_FloatingWindowsLayoutKey = "UnityEditor.ShaderGraph.FloatingWindowsLayout";
string serializedWindowLayout = EditorUserSettings.GetConfigValue(m_FloatingWindowsLayoutKey);
if (!String.IsNullOrEmpty(serializedWindowLayout))
if (m_FloatingWindowsLayout != null)
m_FloatingWindowsLayout.defaultPreviewLayout.CalculateDockingCornerAndOffset(m_MasterPreviewView.layout, layout);
m_FloatingWindowsLayout.defaultBlackboardLayout.CalculateDockingCornerAndOffset(m_BlackboardProvider.blackboard.layout, layout);
if (m_FloatingWindowsLayout == null)
m_FloatingWindowsLayout = new FloatingWindowsLayout();
m_FloatingWindowsLayout.masterPreviewSize = m_MasterPreviewView.Q("preview").layout.size;
EditorUserSettings.SetConfigValue(m_FloatingWindowsLayoutKey, serializedWindowLayout);
EditorUserSettings.SetConfigValue(k_FloatingWindowsLayoutKey, serializedWindowLayout);
m_MasterPreviewView.RefreshRenderTextureSize();
using MouseButton = UnityEngine.Experimental.UIElements.MouseButton;
namespace UnityEditor.ShaderGraph.Drawing.Slots