Ejemplo n.º 1
0
    public RootHistory(Element element)
    {
        bool   flg      = false;
        string filepath = Application.persistentDataPath + "/history.json";

        if (!File.Exists(filepath))
        {
            RootHistory root = new RootHistory();
            string      str  = JsonUtility.ToJson(root, true);

            File.WriteAllText(Application.persistentDataPath + "/history.json", str);
        }

        string dataAsJson = File.ReadAllText(filepath);

        history = JsonUtility.FromJson <RootHistory>(dataAsJson).history;
        foreach (Element _element in history)
        {
            if (_element.value == element.value)
            {
                flg = true;
            }
        }
        if (!flg)
        {
            history.Add(element);
        }
    }
Ejemplo n.º 2
0
    public static void SaveToHistory(Element element)
    {
        RootHistory historyJSON = new RootHistory(element);

        string str = "";

        str = JsonUtility.ToJson(historyJSON, true);

        File.WriteAllText(Application.persistentDataPath + "/history.json", str);
        Debug.Log(Application.persistentDataPath);
    }
Ejemplo n.º 3
0
    public static List <Element> ShowHistory()
    {
        string filepath = Application.persistentDataPath + "/history.json";

        if (File.Exists(filepath))
        {
            string dataAsJson = File.ReadAllText(filepath);

            RootHistory historyJSON = JsonUtility.FromJson <RootHistory>(dataAsJson);

            return(historyJSON.history);
        }
        return(null);
    }
Ejemplo n.º 4
0
    public static void SaveToHistory(string _value, int _type, int _id)
    {
        Element element = new Element
        {
            id    = _id,
            type  = _type,
            value = _value
        };

        RootHistory historyJSON = new RootHistory(element);

        string str = "";

        str = JsonUtility.ToJson(historyJSON, true);

        File.WriteAllText(Application.persistentDataPath + "/history.json", str);
        Debug.Log(Application.persistentDataPath);
    }