浏览代码

Moved global selection handling into its own manipulator, rather than piggy-backing the ClickSelector, as an edge case was not being handled.

(when the selection didn't change the global selection wouldn't be changed - e.g. "select node in graph, select something from the scene, click selected node" wouldn't select the graph in the project window)
/main
Peter Bay Bastian 8 年前
当前提交
d99fa8d2
共有 3 个文件被更改,包括 52 次插入4 次删除
  1. 15
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializableGraphView.cs
  2. 29
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Manipulators/ClickGlobalSelector.cs
  3. 12
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Manipulators/ClickGlobalSelector.cs.meta

15
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializableGraphView.cs


{Event.KeyboardEvent("tab"), FrameNext}
}));
AddManipulator(new ClickGlobalSelector());
AddManipulator(new ContentZoomer());
AddManipulator(new ContentDragger());
AddManipulator(new RectangleSelector());

AddToSelection(drawer);
}
public void SetGlobalSelection()
{
var graphDataSource = GetPresenter<AbstractGraphDataSource>();
if (graphDataSource == null || graphDataSource.graphAsset == null)
return;
Selection.activeObject = graphDataSource.graphAsset.GetScriptableObject();
}
if (graphDataSource == null || graphDataSource.graphAsset == null) return;
if (graphDataSource == null || graphDataSource.graphAsset == null)
return;
// TODO: Maybe put somewhere else
Selection.activeObject = graphDataSource.graphAsset.GetScriptableObject();
}
public override void AddToSelection(ISelectable selectable)

29
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Manipulators/ClickGlobalSelector.cs


using System;
using RMGUI.GraphView;
using UnityEditor.Graphing.Drawing;
using UnityEngine;
using UnityEngine.RMGUI;
namespace UnityEditor.Graphing.Drawing
{
public class ClickGlobalSelector : MouseManipulator
{
public ClickGlobalSelector()
{
phaseInterest = EventPhase.Capture;
activators.Add(new ManipActivator {button = MouseButton.LeftMouse});
activators.Add(new ManipActivator {button = MouseButton.RightMouse});
}
public override EventPropagation HandleEvent(Event evt, VisualElement finalTarget)
{
var graphView = target as SerializableGraphView;
if (graphView == null)
throw new InvalidOperationException("Manipulator can only be added to a SerializableGraphView");
graphView.SetGlobalSelection();
return EventPropagation.Continue;
}
}
}

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


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