Ejemplo n.º 1
0
    public UIDescription ParseFromJson(string jsonText)
    {
        if (string.IsNullOrEmpty(jsonText))
        {
            Debug.LogError("jsonText is null");
            return(null);
        }

        Dictionary <string, object> config = MiniJSON.Json.Deserialize(jsonText) as Dictionary <string, object>;

        if (config == null)
        {
            Debug.LogError("parse uidescription config failed.");
            return(null);
        }

        UIDescription des = new UIDescription();

        des.CanvasPrefab = GetRealPrefabPath(GetStringFromDict("CanvasPrefab", config));
        des.Prefab       = GetRealPrefabPath(GetStringFromDict("Prefab", config));

        if (config.ContainsKey("Children"))
        {
            IList <UINode> nodes = ParseNodes(config["Children"]);
            des.Children = nodes;
        }

        return(des);
    }
Ejemplo n.º 2
0
    public UIDescription ParseFromJson(string jsonText)
    {
        if (string.IsNullOrEmpty(jsonText))
        {
            Debug.LogError("jsonText is null");
            return null;
        }

        Dictionary<string, object> config = MiniJSON.Json.Deserialize(jsonText) as Dictionary<string, object>;
        if (config == null)
        {
            Debug.LogError("parse uidescription config failed.");
            return null;
        }

        UIDescription des = new UIDescription();
        des.CanvasPrefab = GetRealPrefabPath(GetStringFromDict("CanvasPrefab", config));
        des.Prefab = GetRealPrefabPath(GetStringFromDict("Prefab", config));

        if (config.ContainsKey("Children"))
        {
            IList<UINode> nodes = ParseNodes(config["Children"]);
            des.Children = nodes;
        }

        return des;
    }
Ejemplo n.º 3
0
    public void LoadUIWithDescription(string uiDesPath)
    {
        string path = "UIDescriptions/" + uiDesPath;

        UIDescriptionParser parser = new UIDescriptionParser();

        var json = LoadTextFromPath(path);

        UIDescription uiDes = parser.ParseFromJson(json);

        LoadUIWithDescription(uiDes);
    }
Ejemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        GG                = this.gameObject.GetComponent <GameGod>();
        Unitlist          = new List <SelectController>();
        GameCamera        = GameObject.Find("Main Camera").GetComponent <Camera>();
        Rendercam.enabled = false;

        TName = UIName.GetComponent <Text>();
        TDesc = UIDescription.GetComponent <Text>();
        THP   = UIhp.GetComponent <Text>();

        HPPercent = UISlider.GetComponent <Slider>();
    }
Ejemplo n.º 5
0
    public void LoadUIWithDescription(UIDescription uiDes)
    {
        //load canvas & root ui
        LoadCanvas(uiDes.CanvasPrefab);
        if (uiDes.Prefab != null)
        {
            LoadUI(uiDes.Prefab);
        }

        //load children if exists
        if (uiDes.Children != null && uiDes.Children.Count > 0)
        {
            foreach (var c in uiDes.Children)
            {
                GameObject parent = null;
                if (!string.IsNullOrEmpty(c.ParentElementId))
                {
                    parent = elementCenter.Get(c.ParentElementId) as GameObject;
                }

                LoadUI(c, parent);
            }
        }
    }
Ejemplo n.º 6
0
    public void LoadUIWithDescription(UIDescription uiDes)
    {
        //load canvas & root ui
        LoadCanvas(uiDes.CanvasPrefab);
        if (uiDes.Prefab != null)
        {
            LoadUI(uiDes.Prefab);
        }

        //load children if exists
        if (uiDes.Children != null && uiDes.Children.Count > 0)
        {
            foreach (var c in uiDes.Children)
            {
                GameObject parent = null;
                if (!string.IsNullOrEmpty(c.ParentElementId))
                {
                    parent = elementCenter.Get(c.ParentElementId) as GameObject;
                }

                LoadUI(c, parent);
            }
        }
    }