/// <summary>
        /// Creates new transition between specified layout elements.
        /// </summary>
        /// <param name="elementA">Layout element that will be hidden</param>
        /// <param name="elementB">Layout element that will be shown</param>
        /// <param name="offsetTime">
        /// Normalized time of elementA's hide duration that the elementB will wait before start to showing.
        /// For example, a value of 0.5 would mean the elementB will begin showing at 50% of the elementA hide animation time.
        /// </param>
        /// <param name="onComplete">On complete callback</param>
        public UiLayoutTransition(UiLayoutElement elementA, UiLayoutElement elementB, float offsetTime)
        {
            _elementA = elementA;
            _elementB = elementB;

            _offsetTime = offsetTime;
        }
Beispiel #2
0
        // Reorders depth of layout element inside of their containers.
        private static void Reorder()
        {
            for (int index = 0; index < _elements.Count; index++)
            {
                if (_elements[index] == null || _elements[index].Value == null || _elements[index].Value.IsDestroyed)
                {
                    continue;
                }

                UiLayoutElement element = _elements[index].Value;

                int depth = 0;

                if (element is UiLayoutElementScreen)
                {
                    depth = index + (element.IsActive ? 100 : 150);
                }

                if (element is UiLayoutElementPanel)
                {
                    depth = index + (element.IsActive ? 200 : 250);
                }

                if (element is UiLayoutElementPopup)
                {
                    depth = index + (element.IsActive ? 300 : 350);
                }

                element.RectTransform.SetSiblingIndex(depth);

                index++;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Searches UiLayoutElementScreen that was loaded from specified path in Resources folder.
        /// </summary>
        /// <param name="path">Original prefab path in a Resources folder</param>
        /// <returns>UiLayoutElementScreen instance or null if not found</returns>
        public static UiLayoutElementScreen FindScreen(string path)
        {
            UiLayoutElement element = GetElement(path);

            if (element != null && element is UiLayoutElementScreen)
            {
                return(element as UiLayoutElementScreen);
            }

            return(null);
        }
Beispiel #4
0
        // Adds new layout element to list
        private static void AddElement(string path, UiLayoutElement element)
        {
            if (GetElement(path) != null)
            {
                return;
            }

            _elements.Add(new CommonPair <string, UiLayoutElement>(path, element));

            Reorder();
        }
Beispiel #5
0
        /// <summary>
        /// Searches UiLayoutElementPanel that was loaded from specified path in Resources folder.
        /// </summary>
        /// <param name="path">Original prefab path in a Resources folder</param>
        /// <returns>UiLayoutElementPanel instance or null if not found</returns>
        public static UiLayoutElementPanel FindPanel(string path)
        {
            UiLayoutElement element = GetElement(path);

            if (element != null && element is UiLayoutElementPanel)
            {
                return(element as UiLayoutElementPanel);
            }

            return(null);
        }
Beispiel #6
0
        /// <summary>
        /// Initializates layout preset.
        /// </summary>
        public void Initialization()
        {
            switch (PresetType)
            {
            case Type.Screen:
                Instance = UiLayout.CreateScreen(PrefabPath, Container);
                Instance.SetActive(false);

                if (ActiveByDefault)
                {
                    if (ActiveByDefaultImmediately)
                    {
                        UiLayout.SetActiveScreenImmediately(Instance as UiLayoutElementScreen);
                    }
                    else
                    {
                        UiLayout.SetActiveScreen(Instance as UiLayoutElementScreen);
                    }
                }
                break;

            case Type.Panel:
                Instance = UiLayout.CreatePanel(PrefabPath, Container);
                Instance.SetActive(false);

                if (ActiveByDefault)
                {
                    if (ActiveByDefaultImmediately)
                    {
                        Instance.ShowImmediately();
                    }
                    else
                    {
                        Instance.Show();
                    }
                }

                break;
            }

            InitializeSignalsShow(OnSignalShow);
            InitializeSignalsHide(OnSignalHide);
        }