﻿using DeJson;
using System.Collections.Generic;
using System;
using System.IO;
using UnityEngine;

namespace HappyFunTimes
{
    public class HFTWebFileLoader
    {
        // TODO: Put this in one place
        static private string HFT_WEB_PATH = "HappyFunTimesAutoGeneratedDoNotEdit/";
        static private string HFT_WEB_DIR = "HappyFunTimesAutoGeneratedDoNotEdit/__dir__";

        static public void LoadFiles(HFTWebFileDB db)
        {
            TextAsset dirTxt = Resources.Load(HFT_WEB_DIR, typeof(TextAsset)) as TextAsset;
            if (dirTxt == null)
            {
                Debug.LogError("could not load: " + HFT_WEB_DIR);
                return;
            }

            Deserializer deserializer = new Deserializer();
            string[] files = deserializer.Deserialize<string[] >(dirTxt.text);

            foreach (string file in files)
            {
                string path = HFT_WEB_PATH + file;
                TextAsset asset = Resources.Load(path) as TextAsset;
                if (asset == null)
                {
                    Debug.LogError("Could not load: " + path);
                }
                else
                {
                    db.AddFile(file, asset.bytes);
                }
            }

        }
    }

}  // namespace HappyFunTimes


﻿using DeJson;
using System.Collections.Generic;
using System;
using System.IO;
using UnityEngine;

namespace HappyFunTimes
{
    public class HFTWebFileLoader
    {
        // TODO: Put this in one place
        static private string HFT_WEB_PATH = "HappyFunTimesAutoGeneratedDoNotEdit/";
        static private string HFT_WEB_DIR = "HappyFunTimesAutoGeneratedDoNotEdit/__dir__";

        static public void LoadFiles(HFTWebFileDB db)
        {
            TextAsset dirTxt = Resources.Load<TextAsset>(HFT_WEB_DIR);
            if (dirTxt == null)
            {
                Debug.LogError("could not load: " + HFT_WEB_DIR);
                return;
            }

            Deserializer deserializer = new Deserializer();
            string[] files = deserializer.Deserialize<string[] >(dirTxt.text);

            foreach (string file in files)
            {
                string path = HFT_WEB_PATH + file;
                TextAsset asset = Resources.Load(path) as TextAsset;
                if (asset == null)
                {
                    Debug.LogError("Could not load: " + path);
                }
                else
                {
                    db.AddFile(file, asset.bytes);
                }
            }

        }
    }

}  // namespace HappyFunTimes


Use templated version of Resources.Load
Use templated version of Resources.Load
