/// <summary> /// Parse the trigger json definition /// </summary> private void Parse(Dictionary<string,object> screen) { // Log.Debug("PARSE Screen: "+screen["id"].ToString()); //TODO we might want to create the game object here? //set parameters gameObject.name = screen["id"].ToString(); nextDefaultScreenName = screen["next"].ToString(); backScreenName = screen["back"].ToString(); string layers = screen["layers"].ToString(); string[] listOfLayers = layers.Split(','); foreach(string layer in listOfLayers) { this.layerMask |= 1 << LayerMask.NameToLayer(layer); } //parse list of objects if(screen.ContainsKey("objects")) { uiManager = UIManager.Instance; screenObjects = uiManager.LoadResources(screen, gameObject); huds = uiManager.GetHudNames(screen); popups = uiManager.GetPopupNames(screen); hudDefaultTransforms = new List<StoreTransform>(); foreach (string hud in huds) { GameObject obj = uiManager.GetHud(hud); StoreTransform transform = new StoreTransform(obj.transform.position, obj.transform.rotation, obj.transform.localScale); hudDefaultTransforms.Add(transform); } } }
/// TODO this might goes to CTOR? /// <summary> /// Basic initialization /// </summary> public virtual void InitScreen() { Log.Assert(nextDefaultScreenName != "", "Missing nextDefaultScreenName, please set one in "+gameObject.name); uiManager = UIManager.Instance; gameManager = GameManager.Instance; audioManager = AudioManager.Instance; i18n = I18nManager.Instance; UIManager.UICamera.cullingMask = layerMask; //set every hud active, which used in this screen if(huds != null && hudDefaultTransforms != null) { Log.Assert(hudDefaultTransforms.Count == huds.Count); for (int i = 0; i < huds.Count; i++) { GameObject obj = uiManager.GetHud(huds[i]); obj.SetActive(true); obj.transform.position = hudDefaultTransforms[i].position; obj.transform.localScale = hudDefaultTransforms[i].localScale; obj.transform.rotation = hudDefaultTransforms[i].rotation; } } //set every popup inactive, which used in this screen if(popups != null) { foreach(string name in popups) { GameObject obj = uiManager.GetPopup(name); obj.SetActive(false); } } }