Unity's addition and modification check on CSV data table

Preface

There are few complete solutions for adding, modifying, and checking this set of CSV data tables on the Internet. It either requires tedious environment configuration and plug-in installation, or a lot of tedious code. Therefore, it can only be realized through continuous exploration and testing.

Demo video

Unity's demonstration of adding, modifying and checking CSV data tables

Demo picture

function code
effect code

code piece

//本页CSV文件的增、改、查代码为肖老师原创,如需转载,请通知作者:[email protected]
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Text;
//using System.Data.OleDb;
using UnityEngine;

public class MakeDB : MonoBehaviour
{
   
    
    
    [SerializeField]
    string inputID = "", inputPWD = "", registerID = "", registerPWD = "";//用户登录、注册数据

    string loginIndex = "", loginID = "", loginPWD = "";//成功登录后的暂存信息

    public string freshScore = "";//记录当前用户最新成绩

    string filePath = "";//记录数据表地址

    // Start is called before the first frame update
    void Start()
    {
   
    
    
        //filePath = Application.streamingAssetsPath + "\\BariumMealExamData.csv";//新建StreamingAssets文件夹,并将BariumMealExamData.csv保存到此文件夹。CSV文件可以直接用Excel或WPS打开。请勿随意删改csv表中的预留信息,以防出错。
        filePath=Application.persistentDataPath+"//"+ "BariumMealExamData.csv";//保存在安卓端的地址,即apk安装后的files文件夹中
    }

    // Update is called once per frame
    void Update()
    {
   
    
    
        Register(registerID, registerPWD);//新用户注册
        Login(inputID, inputPWD);//用户登录
        UpdateScore();//更新用户成绩
    }

    //更新用户成绩
    void 

Guess you like

Origin blog.csdn.net/qq_39889893/article/details/129278033