void Command_SetLayerImage(string data, LayersController.LAYER layer) { string texName = data.Contains(",") ? data.Split(',')[0] : data; Texture2D tex = texName == "null" ? null : Resources.Load("images/Backgrounds/" + texName) as Texture2D; float spd = 2f; bool smooth = false; if (data.Contains(",")) { string[] parameters = data.Split(','); foreach (string p in parameters) { float fVal = 0; bool bVal = false; if (float.TryParse(p, out fVal)) { spd = fVal; continue; } if (bool.TryParse(p, out bVal)) { smooth = bVal; continue; } } } layer.TransitionToTexture(tex, spd, smooth); }
// Update is called once per frame void Update() { LayersController.LAYER layer = null; if (Input.GetKeyDown(KeyCode.Q)) { layer = controller.background; layer.SetTexture(tex); } if (Input.GetKeyDown(KeyCode.F)) { layer = controller.foreground; layer.SetTexture(tex); } if (Input.GetKeyDown(KeyCode.T)) { layer = controller.background; layer.TransitionToTexture(tex, speed, smooth); } }