using System; using System.Collections.Generic; using System.Linq; using UnityEditor.Experimental.GraphView; using UnityEngine; using UnityEngine.UIElements; using UnityEngine.Profiling; namespace UnityEditor.VFX.UI { class VFXOutputParameterDataAnchor : VFXOutputDataAnchor { public static new VFXOutputParameterDataAnchor Create(VFXDataAnchorController controller, VFXNodeUI node) { var anchor = new VFXOutputParameterDataAnchor(controller.orientation, controller.direction, controller.portType, node); anchor.m_EdgeConnector = new VFXEdgeConnector(anchor); anchor.controller = controller; anchor.AddManipulator(anchor.m_EdgeConnector); return anchor; } protected VFXOutputParameterDataAnchor(Orientation anchorOrientation, Direction anchorDirection, Type type, VFXNodeUI node) : base(anchorOrientation, anchorDirection, type, node) { } public override bool ContainsPoint(Vector2 localPoint) { return base.ContainsPoint(localPoint) && !m_ConnectorText.ContainsPoint(this.ChangeCoordinatesTo(m_ConnectorText, localPoint)); } } class VFXInputParameterDataAnchor : VFXDataAnchor { public static new VFXInputParameterDataAnchor Create(VFXDataAnchorController controller, VFXNodeUI node) { var anchor = new VFXInputParameterDataAnchor(controller.orientation, controller.direction, controller.portType, node); anchor.m_EdgeConnector = new EdgeConnector(anchor); anchor.controller = controller; anchor.AddManipulator(anchor.m_EdgeConnector); return anchor; } protected VFXInputParameterDataAnchor(Orientation anchorOrientation, Direction anchorDirection, Type type, VFXNodeUI node) : base(anchorOrientation, anchorDirection, type, node) { } public override bool ContainsPoint(Vector2 localPoint) { return base.ContainsPoint(localPoint) && !m_ConnectorText.ContainsPoint(this.ChangeCoordinatesTo(m_ConnectorText, localPoint)); } } static class UXMLHelper { const string folderName = VisualEffectAssetEditorUtility.editorResourcesFolder; public static string GetUXMLPath(string name) { string path = null; if (s_Cache.TryGetValue(name, out path)) { return path; } return GetUXMLPathRecursive("Assets", name); } static Dictionary s_Cache = new Dictionary(); static string GetUXMLPathRecursive(string path, string name) { Profiler.BeginSample("UXMLHelper.GetUXMLPathRecursive"); string localFileName = path + "/" + folderName + "/" + name; if (System.IO.File.Exists(localFileName)) { Profiler.EndSample(); s_Cache[name] = localFileName; return localFileName; } foreach (var dir in System.IO.Directory.GetDirectories(path)) { if (dir.Length <= folderName.Length || !dir.EndsWith(folderName) || !"/\\".Contains(dir[dir.Length - folderName.Length - 1])) { string result = GetUXMLPathRecursive(dir, name); if (result != null) { Profiler.EndSample(); return result; } } } Profiler.EndSample(); return null; } } class VFXParameterUI : VFXNodeUI { public VFXParameterUI() : base("uxml/VFXParameter") { RemoveFromClassList("VFXNodeUI"); styleSheets.Add(VFXView.LoadStyleSheet("VFXParameter")); styleSheets.Add(EditorGUIUtility.Load("StyleSheets/GraphView/Node.uss") as StyleSheet); RegisterCallback(OnMouseHover); RegisterCallback(OnMouseHover); m_ExposedIcon = this.Q("exposed-icon"); this.AddManipulator(new SuperCollapser()); m_Label = this.Q