Ejemplo n.º 1
0
    private void generateElement(GameObject go, JSON.Object json)
    {
        var rt = go.GetComponent <RectTransform>();

        if (rt)
        {
            rt.anchorMin = new Vector2(0, 0);
            rt.anchorMax = new Vector2(1, 1);
            rt.offsetMin = new Vector2(0, 0);
            rt.offsetMax = new Vector2(1, 1);
        }

        foreach (var component in json.GetArray("components"))
        {
            CreateComponents(go, component.Obj);
        }

        if (json.ContainsKey("fadeOut"))
        {
            go.AddComponent <FadeOut>().duration = json.GetFloat("fadeOut", 0);
        }
    }
Ejemplo n.º 2
0
    private void recursiveAddUI(JSON.Object json, GameObject parent)
    {
        var go = new GameObject(json.GetString("name", "AddUI CreatedPanel"));

        if (parent == null)
        {
            var parentName = json.GetString("parent", "Overlay");

            parent = findServerCreatedPanel(parentName); //Find parent in serverCreatedUI

            if (parent == null)
            {
                parent = findClientPanel(parentName);//Find parent in the client UI

                if (parent == null)
                {
                    return; //Parent doesn't exists
                }
                //Add the GameObject to serverCreatedUI since it's a new UI and destroy old one if it exists
                if (go != null)
                {
                    DestroyPanel(go.name, true);
                }
                serverCreatedUI.Add(go);
            }
        }

        generateElement(go, json);

        go.transform.SetParent(parent.transform, false);

        if (json.ContainsKey("childs"))
        {
            foreach (var child in json.GetArray("childs"))
            {
                recursiveAddUI(child.Obj, go);
            }
        }
    }