浏览代码

Add fixed aspect ratio and initial size to PreviewNode

/main
Jens Holm 7 年前
当前提交
cd7aa840
共有 2 个文件被更改,包括 10 次插入5 次删除
  1. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/PreviewNode.cs
  2. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs

9
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/PreviewNode.cs


public void SetDimensions(float width, float height)
{
m_Width = width;
m_Height = height;
float newSize = Mathf.Clamp(Mathf.Min(width, height), 150f, 1000f);
m_Width = newSize;
m_Height = newSize;
}
public float width

public PreviewNode()
{
name = "Preview";
m_Width = 208f;
m_Height = 208f;
}
protected override MethodInfo GetFunctionToConvert()

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


m_Preview = previewSystem.GetPreview(inNode);
m_Preview.onPreviewChanged += OnPreviewChanged;
node.onReplaced += OnReplaced;
node.onReplaced += OnReplaced;
// From OnDataChange()

void OnResize(Vector2 deltaSize)
{
float updatedWidth = Mathf.Min(leftContainer.layout.width + deltaSize.x, 1000f);
float updatedWidth = leftContainer.layout.width + deltaSize.x;
float updatedHeight = m_PreviewImage.layout.height + deltaSize.y;
PreviewNode previewNode = node as PreviewNode;

void UpdatePreviewTexture(Texture previewTexture)
{
if (previewTexture == null)
if (previewTexture == null)
{
m_PreviewImage.visible = false;
m_PreviewImage.RemoveFromClassList("visible");

正在加载...
取消
保存