Ejemplo n.º 1
0
    private static void LoadProductInfo()
    {
        string persistPath = Application.persistentDataPath + "/Config/ProductCfg.txt";

        if (File.Exists(persistPath))
        {
            string           info             = File.ReadAllText(persistPath);
            ProductCfgNormal productcfgnormal = JsonUtility.FromJson <ProductCfgNormal>(info);
            if (productcfgnormal != null)
            {
                foreach (var p in productcfgnormal.Products)
                {
                    ProductInfosDict[p.ProductID] = p;
                }
            }
        }
        else
        {
            ProductCfg productcfg = Resources.Load <ProductCfg>("Configs/ProductCfg");
            if (productcfg != null)
            {
                foreach (var p in productcfg.Products)
                {
                    ProductInfosDict[p.ProductID] = p;
                }
            }
        }
    }
Ejemplo n.º 2
0
    public static void SaveProductInfo(List <ProductInfo> newInfo)
    {
        ProductCfgNormal newCfg = new ProductCfgNormal();

        newCfg.Products = newInfo;
        string info        = JsonUtility.ToJson(newCfg);
        string persistPath = Application.persistentDataPath + "/Config/ProductCfg.txt";

        Utility.CreateDir(persistPath);
        File.WriteAllText(persistPath, info);
        LoadProductInfo();
    }