-
Notifications
You must be signed in to change notification settings - Fork 830
/
Copy pathShaderGroup.cs
65 lines (55 loc) · 1.94 KB
/
ShaderGroup.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Linq;
using UnityEditor.Experimental.GraphView;
using UnityEditor.Graphing;
using UnityEngine;
using UnityEngine.UIElements;
using ContextualMenuManipulator = UnityEngine.UIElements.ContextualMenuManipulator;
using ContextualMenuPopulateEvent = UnityEngine.UIElements.ContextualMenuPopulateEvent;
using VisualElementExtensions = UnityEngine.UIElements.VisualElementExtensions;
namespace UnityEditor.ShaderGraph
{
sealed class ShaderGroup : Group
{
GraphData m_Graph;
public new GroupData userData
{
get => (GroupData)base.userData;
set => base.userData = value;
}
public ShaderGroup()
{
VisualElementExtensions.AddManipulator(this, new ContextualMenuManipulator(BuildContextualMenu));
style.backgroundColor = new StyleColor(new Color(25 / 255f, 25 / 255f, 25 / 255f, 25 / 255f));
capabilities |= Capabilities.Ascendable;
}
public void BuildContextualMenu(ContextualMenuPopulateEvent evt)
{
}
public override bool AcceptsElement(GraphElement element, ref string reasonWhyNotAccepted)
{
if (element is StackNode stackNode)
{
reasonWhyNotAccepted = "Vertex and Pixel Stacks cannot be grouped";
return false;
}
var nodeView = element as IShaderNodeView;
if (nodeView == null)
{
// sticky notes are not nodes, but still groupable
return true;
}
if (nodeView.node is BlockNode)
{
reasonWhyNotAccepted = "Block Nodes cannot be grouped";
return false;
}
return true;
}
protected override void SetScopePositionOnly(Rect newPos)
{
base.SetScopePositionOnly(newPos);
userData.position = newPos.position;
}
}
}