void LoadSceneState()
    {
        CenarioData data  = SaveState.LoadSceneData(cena);
        GameObject  itens = GameObject.FindGameObjectWithTag("Itens");

        if (data != null)
        {
            Debug.Log(data);
            if (data.itens.Length != 0)
            {
                for (int i = 0; i < data.itens.Length; i++)
                {
                    setItens(data.itens [i]);
                    for (int j = 0; j < itens.transform.childCount; j++)
                    {
                        if (itens.transform.GetChild(j).FindChild(data.itens [i]))
                        {
                            itens.transform.GetChild(j).gameObject.SetActive(false);
                        }
                    }
                    Debug.Log(data.itens [i]);
                }
            }
            else
            {
                Debug.Log("Nenhum item");
            }
        }
    }
コード例 #2
0
    //CENARIO
    public static void SaveSceneData(CenarioController itens)
    {
        CenarioData data = new CenarioData();

        data.itens = new string[itens.itens.Count];
        data.cena  = itens.cena;
        for (int i = 0; i < itens.itens.Count; i++)
        {
            data.itens[i] = itens.itens[i];
        }
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/Temp/Cenario/" + data.cena + ".txt";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        formatter.Serialize(stream, data);
        stream.Close();
    }
コード例 #3
0
    public static CenarioData LoadSceneData(string cena)
    {
        string path = Application.persistentDataPath + "/Temp/Cenario/" + cena + ".txt";

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);
            CenarioData     data      = formatter.Deserialize(stream) as CenarioData;
            stream.Close();
            return(data);
        }
        else
        {
            Debug.Log("Arquivo " + cena + ".txt nao encontrado");
        }
        return(null);
    }