예제 #1
0
        public void SetTarget(OverlayDropZoneBase target)
        {
            if (m_Target == target)
            {
                return;
            }

            if (m_Target != null)
            {
                foreach (var c in m_DropZoneClasses)
                {
                    RemoveFromClassList(c);
                }
            }

            m_Target = target;
            m_DropZoneClasses.Clear();

            if (m_Target != null)
            {
                m_Target.PopulateDestMarkerClassList(m_DropZoneClasses);

                SetBounds(m_Target.GetTargetWorldBounds());
                style.display = DisplayStyle.Flex;
                foreach (var c in m_DropZoneClasses)
                {
                    AddToClassList(c);
                }
            }
            else
            {
                style.display = DisplayStyle.None;
            }
        }
예제 #2
0
        OverlayDropZoneBase GetOverlayDropZone(Vector2 mousePosition, Overlay ignoreTarget)
        {
            //keep mouse position within bounds for picking, mathf.epsilon is too small
            mousePosition.x = Mathf.Clamp(mousePosition.x, canvasRoot.worldBound.xMin + k_Epsilon,
                                          canvasRoot.worldBound.xMax - k_Epsilon);
            mousePosition.y = Mathf.Clamp(mousePosition.y, canvasRoot.worldBound.yMin + k_Epsilon,
                                          canvasRoot.worldBound.yMax - k_Epsilon);

            //get list of items under mouse
            s_PickingBuffer.Clear();
            canvasRoot.panel.PickAll(mousePosition, s_PickingBuffer);

            OverlayDropZoneBase result = null;

            foreach (var visualElement in s_PickingBuffer)
            {
                if (visualElement.parent is OverlayDropZoneBase dropZone &&
                    dropZone.CanAcceptTarget(ignoreTarget) &&
                    (result == null || dropZone.priority > result.priority))
                {
                    result = dropZone;
                }
            }

            return(result);
        }
예제 #3
0
 public ToolbarOverlayContainer()
 {
     AddToClassList(k_ToolbarClassName);
     m_NoElementDropZone = new HiddenToolbarDropZone(this)
     {
         name = "NoElementToolbarDropZone"
     };
     Add(m_NoElementDropZone);
 }