コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (gameDataLoaded == null)
        {
            gameDataLoaded = (GameObject.Find("Save Manager").GetComponent <SaveGameManager>().gameDataLoaded) as GameDataLoaded;
        }
        else if (gameDataLoaded != null && !isLoaded)
        {
            bestDistance.text = Math.Floor(gameDataLoaded.bestDistance) + " M";
            lastDistance.text = Math.Floor(gameDataLoaded.lastDistance) + " M";
            diamound.text     = gameDataLoaded.diamound.ToString();
        }

        CheckAndPlayAudioClip(menuMusic);
    }
コード例 #2
0
    IEnumerator LoadJson()
    {
        var jsonToLoad = BetterStreamingAssets.GetFiles(filePath).Where(x => Path.GetExtension(x) == ".json").ToList();

        while (jsonToLoad.Count != 0)
        {
            var jsonFile = jsonToLoad[0];
            jsonToLoad.RemoveAt(0);
            var jsonText = BetterStreamingAssets.ReadAllText(jsonFile);
            try
            {
                JsonUtility.FromJsonOverwrite(jsonText, this);
            }
            catch (Exception e)
            {
                Debug.Log($"Falha ao carreggar {jsonFile}, erro: {e.Message}");
            }

            yield return(0);
        }

        Loaded = true;
        GameDataLoaded?.Invoke(this, EventArgs.Empty);
    }