您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
51 行
1.4 KiB
51 行
1.4 KiB
using UnityEditor.Graphing;
|
|
using UnityEditor.Graphing.Drawing;
|
|
using UnityEngine;
|
|
using UnityEngine.Graphing;
|
|
using UnityEngine.MaterialGraph;
|
|
|
|
namespace UnityEditor.MaterialGraph
|
|
{
|
|
[CustomNodeUI(typeof(Vector2Node))]
|
|
public class Vector2NodeUI : ICustomNodeUi
|
|
{
|
|
private Vector2Node m_Node;
|
|
|
|
public float GetNodeUiHeight(float width)
|
|
{
|
|
return 2 * EditorGUIUtility.singleLineHeight;
|
|
}
|
|
|
|
public GUIModificationType Render(Rect area)
|
|
{
|
|
if (m_Node == null)
|
|
return GUIModificationType.None;
|
|
|
|
EditorGUI.BeginChangeCheck();
|
|
m_Node.value = EditorGUI.Vector2Field(new Rect(area.x, area.y, area.width, EditorGUIUtility.singleLineHeight), "Value", m_Node.value);
|
|
if (EditorGUI.EndChangeCheck())
|
|
{
|
|
//TODO:tidy this shit.
|
|
//EditorUtility.SetDirty(materialGraphOwner.owner);
|
|
return GUIModificationType.Repaint;
|
|
}
|
|
return GUIModificationType.None;
|
|
}
|
|
|
|
public INode node
|
|
{
|
|
get { return m_Node; }
|
|
set
|
|
{
|
|
var materialNode = value as Vector2Node;
|
|
if (materialNode != null)
|
|
m_Node = materialNode;
|
|
}
|
|
}
|
|
|
|
public float GetNodeWidth()
|
|
{
|
|
return 200;
|
|
}
|
|
}
|
|
}
|