浏览代码

"Show in project"-button now works

/main
Peter Bay Bastian 8 年前
当前提交
be11b1e0
共有 5 个文件被更改,包括 85 次插入0 次删除
  1. 5
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/DrawData/TitleBarButtonDrawData.cs
  2. 9
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/DrawData/TitleBarDrawData.cs
  3. 12
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Drawer/TitleBarButtonDrawer.cs
  4. 47
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Manipulators/Clicker.cs
  5. 12
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Manipulators/Clicker.cs.meta

5
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/DrawData/TitleBarButtonDrawData.cs


using UnityEngine;
namespace UnityEditor.Graphing.Drawing
{
public delegate void OnTitleBarButtonClicked();
public delegate void ClickCallback();
public ClickCallback onClick { get; set; }
protected TitleBarButtonDrawData() { }
}

9
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/DrawData/TitleBarDrawData.cs


{
List<TitleBarButtonDrawData> m_leftItems;
List<TitleBarButtonDrawData> m_rightItems;
IGraphAsset m_graphAsset;
public IEnumerable<TitleBarButtonDrawData> leftItems
{

public void Initialize(IGraphAsset graphAsset)
{
m_graphAsset = graphAsset;
m_leftItems = new List<TitleBarButtonDrawData>();
m_rightItems = new List<TitleBarButtonDrawData>();

var showInProjectItem = CreateInstance<TitleBarButtonDrawData>();
showInProjectItem.text = "Show in project";
showInProjectItem.onClick += OnShowInProjectClick;
}
void OnShowInProjectClick()
{
if (m_graphAsset != null)
EditorGUIUtility.PingObject(m_graphAsset.GetScriptableObject());
}
}
}

12
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Drawer/TitleBarButtonDrawer.cs


public class TitleBarButtonDrawer : DataWatchContainer
{
TitleBarButtonDrawData m_dataProvider;
Clicker m_clicker;
VisualElement m_label;
public TitleBarButtonDrawData dataProvider

{
classList = new ClassList("titleBarItem");
m_clicker = new Clicker();
m_clicker.onClick += OnClick;
AddManipulator(m_clicker);
AddChild(new VisualElement() { classList = new ClassList("titleBarItemBorder") });
m_label = new VisualElement()
{

this.Touch(ChangeType.Repaint);
}
void OnClick()
{
if (m_dataProvider != null && m_dataProvider.onClick != null)
m_dataProvider.onClick();
}
protected override object toWatch
{

47
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Manipulators/Clicker.cs


using System;
using RMGUI.GraphView;
using UnityEngine;
using UnityEngine.RMGUI;
namespace UnityEditor.Graphing.Drawing
{
public class Clicker : MouseManipulator
{
public delegate void StateChangeCallback();
public delegate void ClickCallback();
public ClickCallback onClick { get; set; }
VisualElement initialTarget;
bool withinInitialTarget;
public override EventPropagation HandleEvent(Event evt, VisualElement finalTarget)
{
switch (evt.type)
{
case EventType.MouseDown:
if (CanStartManipulation(evt))
{
this.TakeCapture();
initialTarget = finalTarget;
}
break;
case EventType.MouseUp:
if (CanStopManipulation(evt))
{
this.ReleaseCapture();
withinInitialTarget = initialTarget != null && initialTarget.ContainsPoint(evt.mousePosition);
if (withinInitialTarget && onClick != null)
{
onClick();
}
}
break;
}
return this.HasCapture() ? EventPropagation.Stop : EventPropagation.Continue;
}
}
}

12
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Manipulators/Clicker.cs.meta


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