コード例 #1
0
ファイル: ItemRepository.cs プロジェクト: thedaruma/danyou
        private void LoadGameData()
        {
            // Path.Combine combines strings into a file path
            // Application.StreamingAssets points to Assets/StreamingAssets in the Editor, and the StreamingAssets folder in a build
            string filePath = Path.Combine(Application.streamingAssetsPath, "items.json");

            if (File.Exists(filePath))
            {
                string dataAsJson = File.ReadAllText(filePath);
                string newData    = JsonHelper.AppendItems(dataAsJson);
                Fruits  = JsonHelper.FromJson <Fruit>(newData);
                Sprites = Resources.LoadAll <Sprite>("fruitbody");

                EventManager.TriggerEvent("GameLoaded");
            }
            else
            {
                Debug.LogError("Cannot load game data!");
            }
        }