Beispiel #1
0
        /// <summary>
        /// Loads and instantiates UiLayoutElementPanel stored at path in a Resources folder.
        /// Throws exception if panel with specified path was instantiated before.
        /// </summary>
        /// <param name="path">Prefab path in a Resources folder</param>
        /// <param name="parent">Parent RectTransform</param>
        /// <returns>Instance of UiLayoutElementPanel</returns>
        public static UiLayoutElementPanel CreatePanel(string path, RectTransform parent = null)
        {
            if (GetElement(path) != null)
            {
                throw new Exception("Panel " + path + " is already instantiated. Use UiLayout.FindPanel to get the instance.");
            }

            UiLayoutElementPanel panel = UiObject.Instantiate <UiLayoutElementPanel>
                                         (
                path,
                GetFirstNotContainer(parent, DefaultContainer)
                                         );

            AddElement(path, panel);

            return(panel);
        }
Beispiel #2
0
        /// <summary>
        /// Loads and instantiates UiLayoutElementScreen stored at path in a Resources folder.
        /// Throws exception if screen with specified path was instantiated before.
        /// </summary>
        /// <param name="path">Prefab path in a Resources folder</param>
        /// <param name="parent">Parent RectTransform</param>
        /// <returns>Instance of UiLayoutElementScreen</returns>
        public static UiLayoutElementScreen CreateScreen(string path, RectTransform parent = null)
        {
            if (GetElement(path) != null)
            {
                throw new Exception("Screen " + path + " is already instantiated. Use UiLayout.FindScreen to get the instance.");
            }

            UiLayoutElementScreen screen = UiObject.Instantiate <UiLayoutElementScreen>
                                           (
                path,
                GetFirstNotContainer(parent, DefaultContainer)
                                           );

            AddElement(path, screen);

            return(screen);
        }
Beispiel #3
0
        /// <summary>
        /// Loads, instantiates and shows UiLayoutElementPopup stored at path in a Resources folder.
        /// If popup with specified path was setted up by using UiLayoutSettings in inspector or by using UiLayoutPreset
        /// then it will be created with assigned parameters like parent container and signals to show and hide.
        /// </summary>
        /// <param name="path">Prefab path in a Resources folder</param>
        /// <param name="parent">Parent RectTransform. Leave it null to use default container or container that assigned to UiLayoutPreset.</param>
        /// <returns>Instance of UiLayoutElementPanel</returns>
        public static UiLayoutElementPopup CreatePopup(string path, RectTransform parent = null)
        {
            UiLayoutPreset preset = FindPreset(path);

            UiLayoutElementPopup popup = UiObject.Instantiate <UiLayoutElementPopup>
                                         (
                path,
                GetFirstNotContainer
                (
                    parent,
                    preset != null ? preset.Container : null,
                    DefaultContainer
                )
                                         );

            if (preset != null)
            {
                preset.InitializeSignalsHide(popup.Hide);
            }

            return(popup);
        }