示例#1
0
        private void Start()
        {
            Size = RectTransform.rect.size;

            HashSet <Transform> createdTabs = new HashSet <Transform>();           // A set to prevent duplicate tabs or to prevent making canvas itself a panel
            Transform           tr          = transform;

            while (tr != null)
            {
                createdTabs.Add(tr);
                tr = tr.parent;
            }

            if (initialPanelsAnchored != null)
            {
                CreateAnchoredPanelsRecursively(initialPanelsAnchored.subPanels, dummyPanel, createdTabs);
            }

            for (int i = 0; i < initialPanelsUnanchored.Count; i++)
            {
                CreateInitialPanel(initialPanelsUnanchored[i], null, Direction.None, createdTabs);
            }

            initialPanelsUnanchored         = null;
            initialPanelsAnchored           = null;
            initialPanelsAnchoredSerialized = null;

            LateUpdate();                                                                  // update layout

            RootPanelGroup.Internal.TryChangeSizeOf(dummyPanel, Direction.Left, 20009f);   // Minimize all panels to their minimum size
            RootPanelGroup.Internal.TryChangeSizeOf(dummyPanel, Direction.Top, 20009f);    // Magick number..
            RootPanelGroup.Internal.TryChangeSizeOf(dummyPanel, Direction.Right, 20009f);  // or not?
            RootPanelGroup.Internal.TryChangeSizeOf(dummyPanel, Direction.Bottom, 20009f); // only time will tell _/o_o\_
        }
示例#2
0
 void ISerializationCallbackReceiver.OnAfterDeserialize()
 {
     if (initialPanelsAnchoredSerialized != null && initialPanelsAnchoredSerialized.Count > 0)
     {
         ReadFromSerializedAnchoredPanelProperties(0, out initialPanelsAnchored);
     }
     else
     {
         initialPanelsAnchored = new AnchoredPanelProperties();
     }
 }
示例#3
0
 public void OnAfterDeserialize()
 {
     if (initialPanelsAnchoredSerialized != null && initialPanelsAnchoredSerialized.Count > 0)
     {
         ReadFromSerializedAnchoredPanelProperties(0, out initialPanelsAnchored);
     }
     else
     {
         initialPanelsAnchored = new AnchoredPanelProperties();
     }
 }
示例#4
0
        private void Start()
        {
            Size = RectTransform.rect.size;

            HashSet <Transform> createdTabs = new HashSet <Transform>();           // A set to prevent duplicate tabs or to prevent making canvas itself a panel
            Transform           tr          = transform;

            while (tr)
            {
                createdTabs.Add(tr);
                tr = tr.parent;
            }

            Dictionary <Panel, Vector2> initialSizes = null;

            if (initialPanelsAnchored != null)
            {
                initialSizes = new Dictionary <Panel, Vector2>(initialPanelsAnchoredSerialized.Count);
                CreateAnchoredPanelsRecursively(initialPanelsAnchored.subPanels, dummyPanel, createdTabs, initialSizes);
            }

            for (int i = 0; i < initialPanelsUnanchored.Count; i++)
            {
                CreateInitialPanel(initialPanelsUnanchored[i], null, Direction.None, createdTabs);
            }

            initialPanelsUnanchored         = null;
            initialPanelsAnchored           = null;
            initialPanelsAnchoredSerialized = null;

            LeaveFreeSpace = m_leaveFreeSpace;
            LateUpdate();             // Update layout

            if (m_leaveFreeSpace)
            {
                // Minimize all panels to their minimum size
                dummyPanel.ResizeTo(new Vector2(99999f, 99999f));

                //RootPanelGroup.Internal.TryChangeSizeOf( dummyPanel, Direction.Left, 20009f );
                //RootPanelGroup.Internal.TryChangeSizeOf( dummyPanel, Direction.Top, 20009f ); // Magick number..
                //RootPanelGroup.Internal.TryChangeSizeOf( dummyPanel, Direction.Right, 20009f ); // or not?
                //RootPanelGroup.Internal.TryChangeSizeOf( dummyPanel, Direction.Bottom, 20009f ); // A: just a big random number U_U
            }

            if (initialSizes != null)
            {
                ResizeAnchoredPanelsRecursively(RootPanelGroup, initialSizes);
            }
        }
示例#5
0
        private void AddToSerializedAnchoredPanelProperties(AnchoredPanelProperties props)
        {
            SerializableAnchoredPanelProperties serializedProps = new SerializableAnchoredPanelProperties()
            {
                panel             = props.panel,
                anchorDirection   = props.anchorDirection,
                childCount        = props.subPanels.Count,
                indexOfFirstChild = initialPanelsAnchoredSerialized.Count + 1
            };

            initialPanelsAnchoredSerialized.Add(serializedProps);
            for (int i = 0; i < props.subPanels.Count; i++)
            {
                AddToSerializedAnchoredPanelProperties(props.subPanels[i]);
            }
        }
示例#6
0
        public void OnBeforeSerialize()
        {
            if (initialPanelsAnchoredSerialized == null)
            {
                initialPanelsAnchoredSerialized = new List <SerializableAnchoredPanelProperties>();
            }
            else
            {
                initialPanelsAnchoredSerialized.Clear();
            }

            if (initialPanelsAnchored == null)
            {
                initialPanelsAnchored = new AnchoredPanelProperties();
            }

            AddToSerializedAnchoredPanelProperties(initialPanelsAnchored);
        }
        private void Start()
        {
            Size = RectTransform.rect.size;

            HashSet <Transform> createdTabs = new HashSet <Transform>(); // A set to prevent duplicate tabs or to prevent making canvas itself a panel
            Transform           tr          = transform;

            while (tr)
            {
                createdTabs.Add(tr);
                tr = tr.parent;
            }

            Dictionary <Panel, Vector2> initialSizes = null;

            if (initialPanelsAnchored != null)
            {
                initialSizes = new Dictionary <Panel, Vector2>(initialPanelsAnchoredSerialized.Count);
                CreateAnchoredPanelsRecursively(initialPanelsAnchored.subPanels, dummyPanel, createdTabs, initialSizes);
            }

            for (int i = 0; i < initialPanelsUnanchored.Count; i++)
            {
                CreateInitialPanel(initialPanelsUnanchored[i], null, PanelDirection.None, createdTabs);
            }

            initialPanelsUnanchored         = null;
            initialPanelsAnchored           = null;
            initialPanelsAnchoredSerialized = null;

            LeaveFreeSpace = leaveFreeSpace;
            LateUpdate(); // Update layout

            if (leaveFreeSpace)
            {
                // Minimize all panels to their minimum size
                dummyPanel.ResizeTo(new Vector2(99999f, 99999f));
            }

            if (initialSizes != null)
            {
                ResizeAnchoredPanelsRecursively(RootPanelGroup, initialSizes);
            }
        }
示例#8
0
        private int ReadFromSerializedAnchoredPanelProperties(int index, out AnchoredPanelProperties props)
        {
            SerializableAnchoredPanelProperties serializedProps = initialPanelsAnchoredSerialized[index];
            AnchoredPanelProperties             newProps        = new AnchoredPanelProperties()
            {
                panel           = serializedProps.panel,
                anchorDirection = serializedProps.anchorDirection,
                subPanels       = new List <AnchoredPanelProperties>()
            };

            for (int i = 0; i != serializedProps.childCount; i++)
            {
                AnchoredPanelProperties childProps;
                index = ReadFromSerializedAnchoredPanelProperties(++index, out childProps);
                newProps.subPanels.Add(childProps);
            }

            props = newProps;
            return(index);
        }
示例#9
0
        void ISerializationCallbackReceiver.OnBeforeSerialize()
        {
            if (initialPanelsAnchoredSerialized == null)
            {
                initialPanelsAnchoredSerialized = new List <SerializableAnchoredPanelProperties>();
            }
            else
            {
                initialPanelsAnchoredSerialized.Clear();
            }

            if (initialPanelsAnchored == null)
            {
                initialPanelsAnchored = new AnchoredPanelProperties();
            }

            if (string.IsNullOrEmpty(m_id))
            {
                m_id = System.Guid.NewGuid().ToString();
            }

            AddToSerializedAnchoredPanelProperties(initialPanelsAnchored);
        }