浏览代码

Started the work on adding path functionality to shaders.

/main
Martin Thorzen 7 年前
当前提交
b0ebffa3
共有 1 个文件被更改,包括 36 次插入0 次删除
  1. 36
      com.unity.shadergraph/Editor/Drawing/Blackboard/BlackboardProvider.cs

36
com.unity.shadergraph/Editor/Drawing/Blackboard/BlackboardProvider.cs


using UnityEditor.Graphing;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using UnityEngine.Experimental.UIElements.StyleEnums;
using UnityEngine.Experimental.UIElements.StyleSheets;
namespace UnityEditor.ShaderGraph.Drawing
{

WindowDraggable m_WindowDraggable;
ResizeBorderFrame m_ResizeBorderFrame;
public Blackboard blackboard { get; private set; }
Label m_PathLabel;
public Action onDragFinished
{

{
scrollable = true,
title = assetName,
subTitle = "my awesome subtitle",
m_PathLabel = blackboard.shadow.ElementAt(0).Q<Label>("subTitleLabel");
m_PathLabel.RegisterCallback<MouseDownEvent>(OnMouseDownEvent);
/*
* 1. Register event on double click
* 2. Spawn a text field on top of the label using absolute position
* (tip: add it to blackboard.parent)
* 3. Focus the text field using Focus
*/
m_WindowDraggable = new WindowDraggable(blackboard.shadow.Children().First().Q("header"));
blackboard.AddManipulator(m_WindowDraggable);

foreach (var property in graph.properties)
AddProperty(property);
blackboard.Add(m_Section);
}
void OnMouseDownEvent(MouseDownEvent evt)
{
if (evt.clickCount == 2 && evt.button == (int)MouseButton.LeftMouse)
{
StartEditingPath();
}
}
void StartEditingPath()
{
TextField tField = new TextField();
tField.text = "Muppet";
tField.style.positionType = PositionType.Absolute;
var position = m_PathLabel.ChangeCoordinatesTo(blackboard, Vector2.zero);
tField.style.positionLeft = position.x;
tField.style.positionTop = position.y;
blackboard.shadow.Add(tField);
Debug.Log(m_PathLabel.text);
}
void MoveItemRequested(Blackboard blackboard, int newIndex, VisualElement visualElement)

正在加载...
取消
保存