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); }
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; }
public void LoadUIWithDescription(string uiDesPath) { string path = "UIDescriptions/" + uiDesPath; UIDescriptionParser parser = new UIDescriptionParser(); var json = LoadTextFromPath(path); UIDescription uiDes = parser.ParseFromJson(json); LoadUIWithDescription(uiDes); }
// 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>(); }
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); } } }
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); } } }