Exemplo n.º 1
0
    public void onMouseUp(PointerEventData data)
    {
        Debug.Log("onMouseUp Button = " + container.name);

        //Transform parentView = null;
        //while(parentView )
        //Debug.Log(container.name);
        if (ViewBuilderButton.OnMouseUp != null)
        {
            ViewBuilderButton.OnMouseUp(container.name);
        }

        Transform broadcastObj = container.transform.parent;

        while (broadcastObj.parent.name.IndexOf("Canvas") == -1)
        {
            broadcastObj = broadcastObj.parent;
        }
        broadcastObj.BroadcastMessage("ButtonMouseUp", container.name, SendMessageOptions.DontRequireReceiver);

        if (radioButtonMode)
        {
            if (!radioButtonClicked)
            {
                return;
            }
        }
        deactivate(null);
    }
Exemplo n.º 2
0
 public ViewBuilderButton(Transform panel, ViewComponent _component) : base(panel, _component)
 {
     if (instance == null)
     {
         instance = this;
     }
     createButton();
     createText();
 }
Exemplo n.º 3
0
 // Update is called once per frame
 void Update()
 {
     foreach (var component in arrayOfComponents)
     {
         ViewBuilderButton button = component as ViewBuilderButton;
         if (button != null)
         {
             button.Update();
         }
         ViewBuilderAnimation animation = component as ViewBuilderAnimation;
         if (animation != null)
         {
             animation.Update();
         }
     }
 }
Exemplo n.º 4
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));
                }
            }
        }
    }