OSDN Git Service

Added Assets for main menu
[mindgames/Mindgames_main.git] / Mindgames / Library / PackageCache / com.unity.visualeffectgraph@6.9.0-preview / Editor / GraphView / Elements / VFXBlockUI.cs
1 using System.Collections.Generic;
2 using UnityEditor.Experimental.GraphView;
3 using UnityEngine;
4 using UnityEngine.UIElements;
5 using System.Reflection;
6 using System.Linq;
7 using UnityEngine.Profiling;
8
9 using PositionType = UnityEngine.UIElements.Position;
10
11 namespace UnityEditor.VFX.UI
12 {
13     class VFXBlockUI : VFXNodeUI
14     {
15         Toggle m_EnableToggle;
16
17         public new VFXBlockController controller
18         {
19             get { return base.controller as VFXBlockController; }
20             set { base.controller = value; }
21         }
22
23         public override VFXDataAnchor InstantiateDataAnchor(VFXDataAnchorController controller, VFXNodeUI node)
24         {
25             VFXContextDataAnchorController anchorController = controller as VFXContextDataAnchorController;
26
27             VFXEditableDataAnchor anchor = VFXBlockDataAnchor.Create(anchorController, node);
28             return anchor;
29         }
30
31         protected override bool HasPosition()
32         {
33             return false;
34         }
35
36         public VFXContextUI context
37         {
38             get { return this.GetFirstAncestorOfType<VFXContextUI>(); }
39         }
40
41         public VFXBlockUI()
42         {
43             Profiler.BeginSample("VFXBlockUI.VFXBlockUI");
44             this.AddStyleSheetPath("VFXBlock");
45             pickingMode = PickingMode.Position;
46             m_EnableToggle = new Toggle();
47             m_EnableToggle.RegisterCallback<ChangeEvent<bool>>(OnToggleEnable);
48             titleContainer.Insert(1, m_EnableToggle);
49
50             capabilities &= ~Capabilities.Ascendable;
51             capabilities |= Capabilities.Selectable | Capabilities.Droppable;
52             this.AddManipulator(new SelectionDropper());
53
54             Profiler.EndSample();
55             style.position = PositionType.Relative;
56         }
57
58         // On purpose -- until we support Drag&Drop I suppose
59         public override void SetPosition(Rect newPos)
60         {
61             style.position = PositionType.Relative;
62         }
63
64         void OnToggleEnable(ChangeEvent<bool> e)
65         {
66             controller.model.enabled = !controller.model.enabled;
67         }
68
69         protected override void SelfChange()
70         {
71             base.SelfChange();
72
73             if (controller.model.enabled)
74             {
75                 titleContainer.RemoveFromClassList("disabled");
76             }
77             else
78             {
79                 titleContainer.AddToClassList("disabled");
80             }
81
82             m_EnableToggle.SetValueWithoutNotify(controller.model.enabled);
83             if (inputContainer != null)
84                 inputContainer.SetEnabled(controller.model.enabled);
85             if (settingsContainer != null)
86                 settingsContainer.SetEnabled(controller.model.enabled);
87
88             if (!controller.model.isValid)
89                 AddToClassList("invalid");
90             else
91                 RemoveFromClassList("invalid");
92         }
93
94         public override bool superCollapsed
95         {
96             get { return false; }
97         }
98     }
99 }