Exemplo n.º 1
0
        public static void CreateExpansionLayoutPanel()
        {
            GameObject           gameObject    = new GameObject("LayoutElementPanel");
            RectTransform        rectTransform = CreateRectTransform(gameObject, Selection.activeTransform);
            UiLayoutElementPanel element       = gameObject.AddComponent <UiLayoutElementPanel>();

            Selection.activeObject = gameObject;
        }
Exemplo n.º 2
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);
        }