private void ApplySettings() { // set background image(s) if (settings.ContainsKey("background") && settings["background"].ContainsKey("images")) { float rotateBackgroundMinutes = settings["background"]["rotate-minutes"]; backgroundWaitTime = rotateBackgroundMinutes * 60f; Debug.Log("Rotating background pictures every " + backgroundWaitTime + " seconds."); backgroundSprites = new List <Sprite>(); JsonArray backgroundSettings = settings["background"]["images"] as JsonArray; for (int i = 0; i < backgroundSettings.Count; i++) { backgroundSprites.Add(ExhibitUtilities.LoadSpriteFromFile(backgroundSettings[i])); } backgroundSprites.ShuffleList(); backgroundImage.sprite = backgroundSprites[0]; backgroundImage.color = Color.white; StartCoroutine(NextBackgroundImage()); } else { backgroundImage.color = defaultBackgroundColor; } // set highlight color Color highlightColor = defaultHightlightColor; ColorUtility.TryParseHtmlString(settings["highlight-color"], out highlightColor); highlight.color = highlightColor; exitButton.color = highlightColor; // set app icons JsonArray appSettings = settings["apps"] as JsonArray; for (int i = 0; i < appSettings.Count; i++) { GameObject iconObject = Instantiate(iconPrefab); iconObject.transform.SetParent(this.transform); Icon iconSettings = iconObject.GetComponent <Icon>(); iconSettings.ChangeIcon(appSettings[i]["icon-image"]); iconSettings.SetLaunchPath(appSettings[i]["launch-path"]); iconSettings.highlight = highlight.GetComponent <RectTransform>(); iconSettings.exitButton = exitButton; if (i == 0) { iconObject.GetComponent <Button>().Select(); } } }
public void ChangeIcon(string iconPath) { if (iconPath != "") { if (!iconPath.StartsWith("C:")) { iconPath = Application.streamingAssetsPath + "/Icons/" + iconPath; } image.sprite = ExhibitUtilities.LoadSpriteFromFile(iconPath); image.color = Color.white; } }