Esempio n. 1
0
    void SaveTotes()
    {
        string toteDataToExportPath = "Assets/Data/ToteData/" + "toteDataImport_200218_ExampleB.totecol";

        ToteCollection totesState = new ToteCollection();

        for (int i = 0; i < allTotes.Count; i++)
        {
            List <ProductDataItem> productsToAdd = new List <ProductDataItem>();
            foreach (Product product in allTotes[i].toteProducts)
            {
                productsToAdd.Add(new ProductDataItem(product.productId));
            }

            totesState.allTotes.Add(new ToteDataItem(productsToAdd, allTotes[i].number, allTotes[i].gridPos));
        }

        Debug.Log(totesState.allTotes.Count);

        string dataToExport = JsonUtility.ToJson(totesState, true);

        Debug.Log(dataToExport);

        System.IO.File.WriteAllText(toteDataToExportPath, dataToExport);
    }
Esempio n. 2
0
    public void LoadSavedTotes()
    {
        List <Tote> totesToLoad = new List <Tote>();

        ToteCollection totesState = new ToteCollection();

        string _settingsImportString = System.IO.File.ReadAllText("Assets/Data/ToteData/" + "toteDataImport_200218_ExampleB.totecol");

        totesState = JsonUtility.FromJson <ToteCollection>(_settingsImportString);
        List <ToteDataItem> toteDataItemsToLoad = new List <ToteDataItem>();

        toteDataItemsToLoad = totesState.allTotes;

        for (int i = 0; i < toteDataItemsToLoad.Count; i++)
        {
            Node nodeToLoadTo = structure.nodesArray[toteDataItemsToLoad[i].gridPos.x, toteDataItemsToLoad[i].gridPos.y, toteDataItemsToLoad[i].gridPos.z];

            List <ProductDataItem> productDataItemsToLoad = new List <ProductDataItem>();
            productDataItemsToLoad = toteDataItemsToLoad[i].toteProducts;

            Debug.Log(productDataItemsToLoad.Count);

            AddTote(nodeToLoadTo, toteDataItemsToLoad[i].number, productDataItemsToLoad[0].productId, productDataItemsToLoad.Count);
        }
    }