Ejemplo n.º 1
0
    private void createText()
    {
        ViewComponent textComponent = new ViewComponent();

        textComponent.id        = component.id + "_text";
        textComponent.groupId   = component.id;
        textComponent.text      = component.text;
        textComponent.textArray = component.textArray;
        textComponent.x         = 0;
        textComponent.y         = 0;
        text = new ViewBuilderText(container.transform, textComponent);
    }
Ejemplo n.º 2
0
    private void createText()
    {
        ViewComponent textComponent = new ViewComponent();

        textComponent.id        = component.id + "_text";
        textComponent.groupId   = "";
        textComponent.text      = component.text;
        textComponent.textArray = component.textArray;
        textComponent.x         = 0;
        textComponent.y         = 0;
        text = new ViewBuilderText(button.transform, textComponent);
        text.hideText(1);
    }
Ejemplo n.º 3
0
    private void init()
    {
        XmlSerializer serializer = new XmlSerializer(typeof(ViewBuilderXML));

        print(Application.dataPath);
        foreach (AppViewsView appView in config.Views)
        {
            string path = config.viewPath + appView.file;
            Log.Instance.Info("Loading view = " + path);
            using (Stream reader = new FileStream(path, FileMode.Open))
            {
                GameObject gameObjectParent = GameObject.Find(appView.idCanvas);

                viewXML = (ViewBuilderXML)serializer.Deserialize(reader);
                // Create game object da view
                GameObject view = new GameObject();
                view.name = viewXML.id;
                GameObject gameObjectCanvas = gameObjectParent.transform.Find("UIContainer").gameObject;
                view.transform.parent = gameObjectCanvas.transform;
                view.transform.SetSiblingIndex(0);
                RectTransform rectTransform = view.AddComponent <RectTransform>();
                rectTransform.localScale = Vector3.one;
                if ((viewXML.width != 0) && (viewXML.height != 0))
                {
                    Vector2 size = new Vector2(viewXML.width, viewXML.height);
                    rectTransform.sizeDelta = size;
                }
                if (viewXML.origPosition.ToLower() == "lowerleft")
                {
                    rectTransform.localPosition = new Vector3(viewXML.x - viewXML.width / 2, viewXML.y - viewXML.height / 2);
                }
                else
                {
                    rectTransform.localPosition = new Vector3(viewXML.x, viewXML.y);
                }

                foreach (ViewComponent component in viewXML.Components)
                {
                    ViewBuilderBaseComponent baseComponent;
                    if (component.type == "GROUP")
                    {
                        baseComponent = new ViewBuilderGroup(view.transform, component);
                    }
                    else if (component.type == "BUTTON")
                    {
                        baseComponent = new ViewBuilderButton(view.transform, component);
                    }
                    else if (component.type == "IMAGE")
                    {
                        baseComponent = new ViewBuilderImage(view.transform, component);
                    }
                    else if (component.type == "TEXTAREA")
                    {
                        baseComponent = new ViewBuilderText(view.transform, component);
                    }
                    else if (component.type == "ANIMATION")
                    {
                        baseComponent = new ViewBuilderAnimation(view.transform, component);
                    }
                    else if (component.type == "INPUT")
                    {
                        baseComponent = new ViewBuilderInput(view.transform, component);
                    }
                    else if (component.type == "SLIDER")
                    {
                        baseComponent = new ViewBuilderSlider(view.transform, component);
                    }
                    else if (component.type == "DROPDOWN")
                    {
                        baseComponent = new ViewBuilderDropdown(view.transform, component);
                    }
                    else if (component.type == "VIDEO")
                    {
                        baseComponent = new ViewBuilderVideo(view.transform, component);
                    }
                    else if (component.type == "MASK")
                    {
                        baseComponent = new ViewBuilderMask(view.transform, component);
                    }
                    else if (component.type == "PLANE")
                    {
                        baseComponent = new ViewBuilderPlane(view.transform, component);
                    }
                    else
                    {
                        baseComponent = new ViewBuilderBaseComponent();
                    }
                    arrayOfComponents.Add(baseComponent);
                }

                if (viewXML.script != null)
                {
                    view.AddComponent(Type.GetType("Assets.Scripts." + viewXML.script));
                }
            }
        }
    }