浏览代码

Put resize handles as invisible bars on edges of inspector window

/main
Jens Holm 7 年前
当前提交
4978e50e
共有 2 个文件被更改,包括 79 次插入9 次删除
  1. 44
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs
  2. 44
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss

44
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs


{
public class GraphInspectorView : VisualElement, IDisposable
{
enum ResizeDirection
{
Any,
Vertical,
Horizontal
}
int m_SelectionHash;
VisualElement m_PropertyItems;

foreach (var property in m_Graph.properties)
m_PropertyItems.Add(new ShaderPropertyView(m_Graph, property));
var resizeHandle = new Label { name = "resize", text = "" };
resizeHandle.AddManipulator(new Draggable(OnResize));
Add(resizeHandle);
var resizeHandleTop = new Label { name = "resize-top", text = "" };
resizeHandleTop.AddManipulator(new Draggable(mouseDelta => OnResize(mouseDelta, ResizeDirection.Vertical, true)));
Add(resizeHandleTop);
var resizeHandleRight = new Label { name = "resize-right", text = "" };
resizeHandleRight.AddManipulator(new Draggable(mouseDelta => OnResize(mouseDelta, ResizeDirection.Horizontal, false)));
Add(resizeHandleRight);
var resizeHandleLeft = new Label { name = "resize-left", text = "" };
resizeHandleLeft.AddManipulator(new Draggable(mouseDelta => OnResize(mouseDelta, ResizeDirection.Horizontal, true)));
Add(resizeHandleLeft);
var resizeHandleBottom = new Label { name = "resize-bottom", text = "" };
resizeHandleBottom.AddManipulator(new Draggable(mouseDelta => OnResize(mouseDelta, ResizeDirection.Vertical, false)));
Add(resizeHandleBottom);
// Nodes missing custom editors:
// - PropertyNode

};
}
void OnResize(Vector2 resizeDelta)
void OnResize(Vector2 resizeDelta, ResizeDirection direction, bool moveWhileResize)
if (direction == ResizeDirection.Vertical)
{
normalizedResizeDelta.x = 0f;
}
else if (direction == ResizeDirection.Horizontal)
{
normalizedResizeDelta.y = 0f;
}
if (moveWhileResize)
{
style.positionLeft += normalizedResizeDelta.x;
style.positionTop += normalizedResizeDelta.y;
normalizedResizeDelta *= -1f;
}
style.width = Mathf.Max(style.width + normalizedResizeDelta.x, 60f);
style.height = Mathf.Max(style.height + normalizedResizeDelta.y, 60f);

44
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss


padding-bottom: 4;
}
GraphInspectorView > #resize {
cursor: resize-up-left;
background-image : resource("GraphView/Nodes/NodeChevronLeft.png");
GraphInspectorView > #resize-right {
cursor: resize-horizontal;
background-color: rgba(0, 0, 0, 0);
width: 16;
height: 16;
width: 5;
position-right: 0;
position-top: 0;
position-bottom: 0;
}
GraphInspectorView > #resize-left {
cursor: resize-horizontal;
background-color: rgba(0, 0, 0, 0);
position-type: absolute;
width: 5;
position-left: 0;
position-top: 0;
position-bottom: 0;
padding-left: 0;
margin-left: 0;
}
GraphInspectorView > #resize-top {
cursor: resize-vertical;
background-color: rgba(0, 0, 0, 0);
position-type: absolute;
height: 5;
position-left: 0;
position-right: 0;
position-top: 0;
padding-top: 0;
margin-top: 0;
}
GraphInspectorView > #resize-bottom {
cursor: resize-vertical;
background-color: rgba(0, 0, 0, 0);
position-type: absolute;
height: 5;
position-left: 0;
position-right: 0;
position-bottom: 0;
}

正在加载...
取消
保存