1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- using System.Collections.Generic;
- using UnityEditor.Experimental.GraphView;
- using UnityEngine;
- using UnityEngine.UIElements;
- using System.Reflection;
- using System.Linq;
- using UnityEngine.Profiling;
- using PositionType = UnityEngine.UIElements.Position;
- namespace UnityEditor.VFX.UI
- {
- class VFXBlockUI : VFXNodeUI
- {
- Toggle m_EnableToggle;
- public new VFXBlockController controller
- {
- get { return base.controller as VFXBlockController; }
- set { base.controller = value; }
- }
- protected override bool HasPosition()
- {
- return false;
- }
- public VFXContextUI context
- {
- get { return this.GetFirstAncestorOfType<VFXContextUI>(); }
- }
- public VFXBlockUI()
- {
- Profiler.BeginSample("VFXBlockUI.VFXBlockUI");
- this.AddStyleSheetPath("VFXBlock");
- pickingMode = PickingMode.Position;
- m_EnableToggle = new Toggle();
- m_EnableToggle.RegisterCallback<ChangeEvent<bool>>(OnToggleEnable);
- titleContainer.Insert(1, m_EnableToggle);
- capabilities &= ~Capabilities.Ascendable;
- capabilities |= Capabilities.Selectable | Capabilities.Droppable;
- this.AddManipulator(new SelectionDropper());
- Profiler.EndSample();
- style.position = PositionType.Relative;
- }
- // On purpose -- until we support Drag&Drop I suppose
- public override void SetPosition(Rect newPos)
- {
- style.position = PositionType.Relative;
- }
- void OnToggleEnable(ChangeEvent<bool> e)
- {
- controller.model.enabled = !controller.model.enabled;
- }
- protected override void SelfChange()
- {
- base.SelfChange();
- if (controller.model.enabled)
- RemoveFromClassList("block-disabled");
- else
- AddToClassList("block-disabled");
- m_EnableToggle.SetValueWithoutNotify(controller.model.enabled);
- if (!controller.model.isValid)
- AddToClassList("invalid");
- else
- RemoveFromClassList("invalid");
- }
- public override bool superCollapsed
- {
- get { return false; }
- }
- }
- }
|