浏览代码

Extracted NodePreviewDrawer from MaterialNodeDrawer

/main
Peter Bay Bastian 8 年前
当前提交
cdc2bd79
共有 3 个文件被更改,包括 33 次插入14 次删除
  1. 17
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Drawer/MaterialNodeDrawer.cs
  2. 18
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Drawer/NodePreviewDrawer.cs
  3. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Drawer/NodePreviewDrawer.cs.meta

17
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Drawer/MaterialNodeDrawer.cs


var previews = nodeData.elements.OfType<NodePreviewDrawData>().ToList();
if (previews.ItemsReferenceEquals(m_currentPreviewData))
{
for (int i = 0; i < previews.Count; i++)
{
var preview = previews[i];
// TODO: Need to share the texture
// right now it's allocating all the time.
preview.Render(new Vector2(200, 200));
}
}
else
if (!previews.ItemsReferenceEquals(m_currentPreviewData))
{
m_PreviewContainer.ClearChildren();
m_currentPreviewData = previews;

var image = preview.Render(new Vector2(200, 200));
var thePreview = new Image
var thePreview = new NodePreviewDrawer
image = image,
data = preview,
name = "image"
};
m_PreviewContainer.AddChild(thePreview);

18
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Drawer/NodePreviewDrawer.cs


using UnityEngine;
using UnityEngine.RMGUI;
namespace UnityEditor.MaterialGraph.Drawing
{
public class NodePreviewDrawer : Image
{
public NodePreviewDrawData data;
public NodePreviewDrawer() {}
public override void DoRepaint(PaintContext args)
{
image = data.Render(new Vector2(200, 200));
base.DoRepaint(args);
}
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Drawer/NodePreviewDrawer.cs.meta


fileFormatVersion: 2
guid: 9a9f5c37df5e44eaf86f0e83ff7fe249
timeCreated: 1476866175
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存