Пример #1
0
        public void CancelDraggingPanel()
        {
            if (draggedPanel != null)
            {
                if (draggedPanel.RectTransform.parent != draggedPanel.Canvas.RectTransform)
                {
                    draggedPanel.RectTransform.SetParent(draggedPanel.Canvas.RectTransform, false);
                    draggedPanel.RectTransform.SetAsLastSibling();
                }

                AnchorZonesSetActive(false);

                UnanchoredPanelGroup unanchoredGroup = draggedPanel.Group as UnanchoredPanelGroup;
                if (unanchoredGroup != null)
                {
                    unanchoredGroup.RestrictPanelToBounds(draggedPanel);
                }

                draggedPanel.Internal.Stop();
                draggedPanel = null;
            }

            hoveredAnchorZone = null;

            if (previewPanel.gameObject.activeSelf)
            {
                previewPanel.gameObject.SetActive(false);
            }
        }
Пример #2
0
        private void Awake()
        {
            RectTransform = (RectTransform)transform;
            UnityCanvas   = GetComponentInParent <Canvas>();
#if !UNITY_EDITOR
            Internal = new InternalSettings(this);
#endif

            UnanchoredPanelGroup = new UnanchoredPanelGroup(this);
            RectTransform.ChangePivotWithoutAffectingPosition(new Vector2(0.5f, 0.5f));

            if (!GetComponent <RectMask2D>())
            {
                gameObject.AddComponent <RectMask2D>();
            }

            Size = RectTransform.rect.size;

            InitializeRootGroup();
            InitializeAnchorZones();

            background = GetComponent <Graphic>();
            if (!background)
            {
                background = gameObject.AddComponent <NonDrawingGraphic>();
                background.raycastTarget = false;
            }

            PanelManager.Instance.RegisterCanvas(this);
        }
        private void Awake()
        {
            RectTransform = (RectTransform)transform;
            UnityCanvas   = GetComponentInParent <Canvas>();
#if !UNITY_EDITOR
            Internal = new InternalSettings(this);
#endif

            UnanchoredPanelGroup = new UnanchoredPanelGroup(this);
            RectTransform.pivot  = new Vector2(0.5f, 0.5f);

            if (GetComponent <RectMask2D>() == null)
            {
                gameObject.AddComponent <RectMask2D>();
            }

            Size = RectTransform.rect.size;

            InitializeRootGroup();
            InitializeAnchorZones();

            background = GetComponent <Image>();
            if (background == null)
            {
                background               = gameObject.AddComponent <Image>();
                background.sprite        = dummyPanel.Internal.BackgroundSprite;
                background.color         = Color.clear;
                background.raycastTarget = false;
            }

            PanelManager.Instance.RegisterCanvas(this);
        }
Пример #4
0
        private void OnEnable()
        {
            UnanchoredPanelGroup unanchoredGroup = Group as UnanchoredPanelGroup;

            if (unanchoredGroup != null)
            {
                unanchoredGroup.RestrictPanelToBounds(this);
                RectTransform.SetAsLastSibling();
            }
        }
Пример #5
0
        private void OnEnable()
        {
            UnanchoredPanelGroup unanchoredGroup = Group as UnanchoredPanelGroup;

            if (unanchoredGroup != null)
            {
                unanchoredGroup.RestrictPanelToBounds(this);
                RectTransform.SetAsLastSibling();
            }

            if (!Internal.IsDummy)
            {
                PanelNotificationCenter.Internal.PanelBecameActive(this);
            }
        }