Beispiel #1
0
        override internal void Visit(Panel panelDescr, PanelBase panelUI)
        {
            string text_name   = NamesFormatter.ObjectName(this.Name, "Label");
            var    text_object = PrefabsHelper.CreateObject("Text", text_name);
            var    c_text      = text_object.GetComponent <UnityEngine.UI.Text>();

            c_text.text = text;
            text_object.transform.SetParent(panelUI.transform);
        }
Beispiel #2
0
        public string[] GetPanelsDeclaration()
        {
            string[] fields = new string[Panels.Length];
            int      index  = 0;

            foreach (var panel in Panels)
            {
                string field_name_downcase = NamesFormatter.PrivateMember(panel.ClassName, "");
                string field_decl          = string.Format("{0} _{1};",
                                                           panel.ClassName, field_name_downcase);

                fields[index++] = field_decl;
            }

            return(fields);
        }
Beispiel #3
0
        override internal void Visit(Panel panelDescr, PanelBase panelUI)
        {
            var    fields      = panelDescr.ComponentType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
            string button_name = NamesFormatter.ObjectName(this.Name, "Button");

            var button = PrefabsHelper.CreateObject("Button", button_name);

            button.transform.SetParent(panelUI.transform);

            UnityButton ui_button = button.GetComponent <UnityButton>();

            string field_name = NamesFormatter.PrivateMember(this.Name, "Button");

            foreach (var field in fields)
            {
                if (field.Name == field_name)
                {
                    field.SetValue(panelUI, ui_button);
                }
            }
        }
Beispiel #4
0
        override internal void Visit(Panel panelDescr, PanelBase panelUI)
        {
            string list_name = NamesFormatter.ObjectName(this.Name, "List");

            var list = PrefabsHelper.CreateObject("Scroll View", list_name);

            list.transform.SetParent(panelUI.transform);
            list.transform.ResetTransform();

            /*
             * var fields = panelDescr.ComponentType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
             * string field_name = NamesFormatter.PrivateMember(this.Name, "List");
             * foreach(var field in fields)
             *{
             *    if (field.Name == field_name)
             *    {
             *        field.SetValue(panelUI, list);
             *    }
             *}
             */
        }
Beispiel #5
0
 public override string Declaration()
 {
     return("Button " + NamesFormatter.PrivateMember(name, "Button") + ";");
 }
Beispiel #6
0
        private void CreateUnityObjects(UIDesciption uiDesc)
        {
            var mainSceneStructure = new MainSceneStructure();

            foreach (var screen in uiDesc.Screens)
            {
                GameObject sc = new GameObject(NamesFormatter.PrefabName(screen.ClassName));

                GameObject screen_panels_group = new GameObject(screen.PanelsGroupName);
                screen_panels_group.AddComponent <RectTransform>();
                screen_panels_group.transform.SetParent(mainSceneStructure.Panels.transform);

                Type screen_type = screen.ComponentType;
                sc.AddComponent(screen_type);

                sc.transform.SetParent(mainSceneStructure.ScreenManager.transform);

/*
 *
 *                // Commented because BaseScreen finds PanelsGroup on Awake.
 *                // PanelsGroup panels_group_comp = screen_panels_group.AddComponent(typeof(PanelsGroup)) as PanelsGroup;
 *                var panels_field = typeof(BaseScreen).GetField("Panels");
 *                panels_field.SetValue(screen_comp, panels_group_comp);
 *
 */

                foreach (var panel in screen.Panels)
                {
                    GameObject pobj = new GameObject(NamesFormatter.PrefabName(panel.ClassName));
                    pobj.AddComponent <RectTransform>();
                    var panel_type = panel.ComponentType;
                    var panel_comp = pobj.AddComponent(panel_type);
                    pobj.transform.SetParent(screen_panels_group.transform);

                    if (panel.Elements != null)
                    {
                        foreach (var element in panel.Elements)
                        {
                            element.Visit(panel, panel_comp as PanelBase);
                        }
                    }

                    /*
                     * string field_name = "_" + Screen.MakeFieldName(panel_type.Name);
                     * var fields = screen_type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
                     */
                    //var field = screen_type.GetField(field_name, BindingFlags.NonPublic | BindingFlags.Instance);
                    //

                    /*
                     * foreach(var f in fields)
                     *{
                     *    if(f.Name == field_name)
                     *        f.SetValue(screen_comp, panel_comp);
                     *}
                     */

                    PrefabUtility.CreatePrefab("Assets/Bully.UI/Prefabs/Panels/" + pobj.name + ".prefab", pobj, ReplacePrefabOptions.ConnectToPrefab);
                }

                string prefabName = string.Format("Assets/Bully.{0}/Prefabs/Screens/{1}.prefab", s_config.ProjectName, sc.name);
                PrefabUtility.CreatePrefab(prefabName, sc, ReplacePrefabOptions.ConnectToPrefab);
            }
        }