国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

2023-05-29 Unity 2進(jìn)制5——Excel配置表工具

這篇具有很好參考價(jià)值的文章主要介紹了2023-05-29 Unity 2進(jìn)制5——Excel配置表工具。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

一、Excel 讀取操作

(一)打開(kāi) Excel 表

  • IExcelDataReader:從流中讀取 Excel 數(shù)據(jù)
  • DataSet:數(shù)據(jù)集合類(lèi),存儲(chǔ) Excel 數(shù)據(jù)
using Excel; // 引入命名空間

private static void OpenExcel() {
    using (FileStream fs = File.Open(Application.dataPath + "/ArtRes/Excel/PlayerInfo.xlsx", FileMode.Open, FileAccess.Read)) {
        // 傳入excel表的文件流獲取數(shù)據(jù)
        IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(fs);
        // 將excel表中的數(shù)據(jù)轉(zhuǎn)換為DataSet數(shù)據(jù)類(lèi)型 
        DataSet result = excelReader.AsDataSet();
        // 得到Excel文件中的所有表信息
        for (int i = 0; i < result.Tables.Count; i++) {
            Debug.Log("表名:" + result.Tables[i].TableName);
            Debug.Log("行數(shù):" + result.Tables[i].Rows.Count);
            Debug.Log("列數(shù):" + result.Tables[i].Columns.Count);
        }

        fs.Close();
    }
}

(二)獲取單元格信息

  • DataTable:數(shù)據(jù)表類(lèi),表示 Excel 文件中的一個(gè)表
  • DataRow:數(shù)據(jù)行類(lèi),表示某張表中的一行數(shù)據(jù)
private static void ReadExcel() {
    using (FileStream fs = File.Open(Application.dataPath + "/ArtRes/Excel/PlayerInfo.xlsx", FileMode.Open, FileAccess.Read)) {
        IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(fs);
        DataSet result = excelReader.AsDataSet();

        for (int i = 0; i < result.Tables.Count; i++) {
            // 得到其中一張表的具體數(shù)據(jù)
            DataTable table = result.Tables[i];
            // 得到其中一行的數(shù)據(jù)
            // DataRow row = table.Rows[0];
            // 得到行中某一列的信息
            // Debug.Log(row[1].ToString());
            DataRow row;
            for (int j = 0; j < table.Rows.Count; j++) {
                // 得到每一行的信息
                row = table.Rows[j];
                Debug.Log("*********新的一行************");
                for (int k = 0; k < table.Columns.Count; k++) {
                    Debug.Log(row[k].ToString());
                }
            }
        }

        fs.Close();
    }
}

二、Excel 表配置工具

(一)基礎(chǔ)知識(shí)

  1. 添加 Unity 菜單欄按鈕

    通過(guò) Unity 提供的 MenuItem 特性在菜單欄添加選項(xiàng)按鈕

    • 特性名:MenuItem
    • 命名空間:UnityEditor

    規(guī)則一:一定是靜態(tài)方法

    規(guī)則二:菜單欄按鈕必須有至少一個(gè)斜杠,不然會(huì)報(bào)錯(cuò),不支持只有一個(gè)菜單欄入口

    規(guī)則三:這個(gè)特性可以用在任意的類(lèi)當(dāng)中

    [MenuItem("GameTool/Test")]
    private static void Test() {
        AssetDatabase.Refresh();
    }
    
  2. 刷新 Project 窗口內(nèi)容

    • 類(lèi)名:AssetDatabase
    • 命名空間:UnityEditor
    • 方法:Refresh
    AssetDatabase.Refresh();
    
  3. Editor 文件夾

    • Editor 文件夾可以放在項(xiàng)目的任何文件夾下,可以有多個(gè)
    • 放在其中的內(nèi)容,項(xiàng)目打包時(shí)不會(huì)被打包到項(xiàng)目中
    • 一般編輯器相關(guān)代碼都可以放在該文件夾中

(二)配置工具

  • ExcelTool.cs

    用于將 Excel 配置表內(nèi)容生成對(duì)應(yīng)的數(shù)據(jù)結(jié)構(gòu)類(lèi)、容器類(lèi)2 進(jìn)制存儲(chǔ)文件。

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using Excel;
using UnityEditor;
using UnityEngine;

public class ExcelTool
{
    /// <summary>
    /// Excel 存放的路徑
    /// </summary>
    private static readonly string EXCEL_PATH = BinaryDataMgr.EXCEL_PATH;

    /// <summary>
    /// 數(shù)據(jù)結(jié)構(gòu)類(lèi)腳本存儲(chǔ)位置
    /// </summary>
    private static readonly string DATA_CLASS_PATH = BinaryDataMgr.DATA_CLASS_PATH;

    /// <summary>
    /// 數(shù)據(jù)容器類(lèi)腳本存儲(chǔ)位置
    /// </summary>
    private static readonly string DATA_CONTAINER_PATH = BinaryDataMgr.DATA_CONTAINER_PATH;

    /// <summary>
    /// 2進(jìn)制數(shù)據(jù)存儲(chǔ)位置
    /// </summary>
    private static readonly string DATA_BINARY_PATH = BinaryDataMgr.DATA_BINARY_PATH;

    /// <summary>
    /// 2進(jìn)制文件后綴名
    /// </summary>
    private static readonly string BINARY_SUFFIX = BinaryDataMgr.BINARY_SUFFIX;

    /// <summary>
    /// 變量名所在行
    /// </summary>
    private static readonly int VARIABLE_NAME_ROW = BinaryDataMgr.VARIABLE_NAME_ROW;

    /// <summary>
    /// 變量類(lèi)型所在行
    /// </summary>
    private static readonly int VARIABLE_TYPE_ROW = BinaryDataMgr.VARIABLE_TYPE_ROW;

    /// <summary>
    /// 變量主鍵所在行
    /// </summary>
    private static readonly int VARIABLE_KEY_ROW = BinaryDataMgr.VARIABLE_KEY_ROW;

    /// <summary>
    /// 變量主鍵標(biāo)識(shí)符
    /// </summary>
    private static readonly string[] VARIABLE_KEYS = BinaryDataMgr.VARIABLE_KEYS;

    /// <summary>
    /// 數(shù)據(jù)內(nèi)容開(kāi)始的行號(hào)
    /// </summary>
    private static readonly int DATA_BEGIN_ROW_INDEX = BinaryDataMgr.DATA_BEGIN_ROW_INDEX;


    /// <summary>
    /// 生成 Excel 數(shù)據(jù)信息
    /// </summary>
    [MenuItem("GameTool/GenerateExcel")]
    private static void GenerateExcelInfo() {
        DirectoryInfo dInfo = Directory.CreateDirectory(EXCEL_PATH); // 指定路徑的文件夾信息
        FileInfo[]    files = dInfo.GetFiles();                      // 指定路徑下的所有 Excel 文件信息
        for (int i = 0; i < files.Length; i++) {
            // 不是 Excel 文件則跳過(guò)
            if (files[i].Extension != ".xlsx" && files[i].Extension != ".xls") continue;

            // 獲取所有表的數(shù)據(jù)
            DataTableCollection tableCollection; // 數(shù)據(jù)表容器
            using (FileStream fs = new FileStream(files[i].FullName, FileMode.Open, FileAccess.Read)) {
                IExcelDataReader excelDataReader = ExcelReaderFactory.CreateOpenXmlReader(fs);
                tableCollection = excelDataReader.AsDataSet().Tables;
            }

            // 遍歷所有表的信息,生成相應(yīng)內(nèi)容
            foreach (DataTable table in tableCollection) {
                GenerateExcelDataClass(table);  // 生成數(shù)據(jù)結(jié)構(gòu)類(lèi)
                GenerateExcelContainer(table);  // 生成容器類(lèi)
                GenerateExcelBinaryData(table); // 生成2進(jìn)制數(shù)據(jù)
            }
        }
    }

    /// <summary>
    /// 生成 Excel 表對(duì)應(yīng)的數(shù)據(jù)結(jié)構(gòu)類(lèi)
    /// </summary>
    /// <param name="table">數(shù)據(jù)表</param>
    private static void GenerateExcelDataClass(DataTable table) {
        DataRow nameRow = table.Rows[VARIABLE_NAME_ROW]; // 變量名行
        DataRow typeRow = table.Rows[VARIABLE_TYPE_ROW]; // 變量類(lèi)型行

        // 確保數(shù)據(jù)結(jié)構(gòu)類(lèi)腳本路徑存在
        if (!Directory.Exists(DATA_CLASS_PATH)) {
            Directory.CreateDirectory(DATA_CLASS_PATH);
        }

        // 拼接數(shù)據(jù)結(jié)構(gòu)類(lèi)內(nèi)容
        string str = $"public class {table.TableName}\n" +
                     $"{{\n";
        for (int i = 0; i < table.Columns.Count; i++) {
            str += $"    public {typeRow[i]} {nameRow[i]};\n";
        }
        str += "}\n";

        // 覆蓋寫(xiě)入文件并刷新 Project 窗口
        File.WriteAllText($"{DATA_CLASS_PATH}{table.TableName}.cs", str);
        AssetDatabase.Refresh();
    }

    /// <summary>
    /// 生成 Excel 表對(duì)應(yīng)的數(shù)據(jù)容器類(lèi)
    /// </summary>
    /// <param name="table">數(shù)據(jù)表</param>
    private static void GenerateExcelContainer(DataTable table) {
        int     keyIndex = GetKeyColumnIndex(table);
        DataRow typeRow  = table.Rows[VARIABLE_TYPE_ROW]; // 變量類(lèi)型行

        // 確保數(shù)據(jù)容器類(lèi)腳本路徑存在
        if (!Directory.Exists(DATA_CONTAINER_PATH)) {
            Directory.CreateDirectory(DATA_CONTAINER_PATH);
        }

        // 拼接數(shù)據(jù)結(jié)構(gòu)類(lèi)內(nèi)容
        string str = $"using System.Collections.Generic;\n\n" +
                     $"public class {table.TableName}Container\n" +
                     $"{{\n" +
                     $"    public Dictionary<{typeRow[keyIndex]}, {table.TableName}> dataDic = new Dictionary<{typeRow[keyIndex]}, {table.TableName}>();\n" +
                     $"}}\n";

        // 覆蓋寫(xiě)入文件并刷新 Project 窗口
        File.WriteAllText($"{DATA_CONTAINER_PATH}{table.TableName}Container.cs", str);
        AssetDatabase.Refresh();
    }

    /// <summary>
    /// 獲得主鍵所在的列
    /// </summary>
    /// <param name="table"></param>
    /// <returns></returns>
    private static int GetKeyColumnIndex(DataTable table) {
        DataRow row = table.Rows[VARIABLE_KEY_ROW]; // 獲取變量主鍵行
        for (int i = 0; i < table.Columns.Count; i++) {
            // 如果該列內(nèi)容在主鍵標(biāo)識(shí)符內(nèi),則返回該列
            if (VARIABLE_KEYS.Contains(row[i].ToString())) {
                return i;
            }
        }

        return 0; // 否則,返回第一列
    }

    /// <summary>
    /// 生成 Excel 表對(duì)應(yīng)的2進(jìn)制數(shù)據(jù)
    /// </summary>
    /// <param name="table">數(shù)據(jù)表</param>
    private static void GenerateExcelBinaryData(DataTable table) {
        // 確保2進(jìn)制數(shù)據(jù)路徑存在
        if (!Directory.Exists(DATA_BINARY_PATH)) {
            Directory.CreateDirectory(DATA_BINARY_PATH);
        }

        // 創(chuàng)建 2 進(jìn)制文件
        using (FileStream fs = new FileStream($"{DATA_BINARY_PATH}{table.TableName}{BINARY_SUFFIX}", FileMode.OpenOrCreate, FileAccess.Write)) {
            int rowNum = table.Rows.Count - DATA_BEGIN_ROW_INDEX + 1; // -DATA_BEGIN_ROW_INDEX 的原因是前 DATA_BEGIN_ROW_INDEX 行是配置規(guī)則,不是 2 進(jìn)制內(nèi)容

            // 1. 先寫(xiě)入存儲(chǔ)的行數(shù)
            fs.Write(BitConverter.GetBytes(rowNum), 0, 4);

            // 2. 獲取主鍵的變量名
            string keyName  = table.Rows[VARIABLE_NAME_ROW][GetKeyColumnIndex(table)].ToString();
            byte[] keyBytes = Encoding.UTF8.GetBytes(keyName);
            // 先寫(xiě)長(zhǎng)度后寫(xiě)內(nèi)容
            fs.Write(BitConverter.GetBytes(keyBytes.Length), 0, 4);
            fs.Write(keyBytes, 0, keyBytes.Length);

            // 3. 遍歷所有數(shù)據(jù)內(nèi)容,進(jìn)行寫(xiě)入
            DataRow typeRow = table.Rows[VARIABLE_TYPE_ROW];
            for (int i = DATA_BEGIN_ROW_INDEX; i < table.Rows.Count; i++) {
                DataRow row = table.Rows[i];
                for (int j = 0; j < table.Columns.Count; j++) {
                    switch (typeRow[j].ToString()) {
                        case "int":
                            fs.Write(BitConverter.GetBytes(int.Parse(row[j].ToString())), 0, 4);
                            break;
                        case "float":
                            fs.Write(BitConverter.GetBytes(float.Parse(row[j].ToString())), 0, 4);
                            break;
                        case "bool":
                            fs.Write(BitConverter.GetBytes(bool.Parse(row[j].ToString())), 0, 1);
                            break;
                        case "string":
                            byte[] strBytes = Encoding.UTF8.GetBytes(row[j].ToString());
                            fs.Write(BitConverter.GetBytes(strBytes.Length), 0, 4); // 先寫(xiě)入字符串長(zhǎng)度
                            fs.Write(strBytes, 0, strBytes.Length);                 // 再寫(xiě)入字符串內(nèi)容
                            break;
                    }
                }
            }
        }
    }
}
  • BinaryDataMgr.cs

    存儲(chǔ)對(duì)象數(shù)據(jù)為 2 進(jìn)制文件并讀取。

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using UnityEngine;

public class BinaryDataMgr
{
    /// <summary>
    /// 數(shù)據(jù)存儲(chǔ)位置
    /// </summary>
    private static readonly string SAVE_PATH = Application.persistentDataPath + "/Data/";

    /// <summary>
    /// Excel 存放的路徑
    /// </summary>
    public static readonly string EXCEL_PATH = Application.dataPath + "/ArtRes/Excel/";

    /// <summary>
    /// 數(shù)據(jù)結(jié)構(gòu)類(lèi)腳本存儲(chǔ)位置
    /// </summary>
    public static readonly string DATA_CLASS_PATH = Application.dataPath + "/Scripts/ExcelData/DataClass/";

    /// <summary>
    /// 數(shù)據(jù)容器類(lèi)腳本存儲(chǔ)位置
    /// </summary>
    public static readonly string DATA_CONTAINER_PATH = Application.dataPath + "/Scripts/ExcelData/Container/";

    /// <summary>
    /// 2進(jìn)制數(shù)據(jù)存儲(chǔ)位置
    /// </summary>
    public static readonly string DATA_BINARY_PATH = Application.streamingAssetsPath + "/Binary/";

    /// <summary>
    /// 2進(jìn)制文件后綴名
    /// </summary>
    public static readonly string BINARY_SUFFIX = ".hl";

    /// <summary>
    /// 變量名所在行
    /// </summary>
    public static readonly int VARIABLE_NAME_ROW = 0;

    /// <summary>
    /// 變量類(lèi)型所在行
    /// </summary>
    public static readonly int VARIABLE_TYPE_ROW = 1;

    /// <summary>
    /// 變量主鍵所在行
    /// </summary>
    public static readonly int VARIABLE_KEY_ROW = 2;

    /// <summary>
    /// 變量主鍵標(biāo)識(shí)符
    /// </summary>
    public static readonly string[] VARIABLE_KEYS = { "key", "Key", "KEY" };

    /// <summary>
    /// 數(shù)據(jù)內(nèi)容開(kāi)始的行號(hào)
    /// </summary>
    public static readonly int DATA_BEGIN_ROW_INDEX = 4;

    /// <summary>
    /// 存儲(chǔ)所有 Excel 表的容器
    /// </summary>
    private Dictionary<string, object> tableDic = new Dictionary<string, object>();
    
    public static BinaryDataMgr Instance { get; set; } = new BinaryDataMgr(); // 需要放在所有字段的最后,保證其他字段先被初始化

    private BinaryDataMgr() {
        InitData();
    }

    /// <summary>
    /// 初始化表格數(shù)據(jù)
    /// </summary>
    private void InitData() {
        // LoadTable<TowerInfoContainer, TowerInfo>();
    }

    /// <summary>
    /// 加載 Excel 表的2進(jìn)制數(shù)據(jù)到內(nèi)存中
    /// </summary>
    /// <typeparam name="T">容器類(lèi)名</typeparam>
    /// <typeparam name="K">數(shù)據(jù)結(jié)構(gòu)體類(lèi)名</typeparam>
    public void LoadTable<T, K>() {
        using (FileStream fs = new FileStream($"{DATA_BINARY_PATH}{typeof(K)}{BINARY_SUFFIX}", FileMode.Open, FileAccess.Read)) {
            int offset = 0; // 讀取偏移量

            // 讀取行數(shù)
            byte[] rowCountBytes = StreamRead(fs, ref offset, 4);
            int    rowCount      = BitConverter.ToInt32(rowCountBytes, 0);

            // 讀取主鍵名
            byte[] keyNameLengthBytes = StreamRead(fs, ref offset, 4); // 主鍵名長(zhǎng)度
            int    keyNameLength      = BitConverter.ToInt32(keyNameLengthBytes, 0);
            byte[] keyNameBytes       = StreamRead(fs, ref offset, keyNameLength); // 主鍵名內(nèi)容
            string keyName            = Encoding.UTF8.GetString(keyNameBytes, 0, keyNameLength);

            // 創(chuàng)建容器類(lèi)對(duì)象
            Type   containerType = typeof(T);
            object container     = Activator.CreateInstance(containerType); // 實(shí)例化容器

            Type        classType = typeof(K);
            FieldInfo[] infos     = classType.GetFields(); // 數(shù)據(jù)結(jié)構(gòu)類(lèi)所有字段的信息

            // 實(shí)例化表的數(shù)據(jù)內(nèi)容
            for (int i = 0; i < rowCount; i++) {
                // 實(shí)例化數(shù)據(jù)結(jié)構(gòu)類(lèi) 對(duì)象
                object dataObj = Activator.CreateInstance(classType);
                foreach (FieldInfo info in infos) {
                    if (info.FieldType == typeof(int)) {
                        byte[] bytes = StreamRead(fs, ref offset, 4);
                        int    value = BitConverter.ToInt32(bytes, 0);
                        info.SetValue(dataObj, value);
                    }
                    else if (info.FieldType == typeof(float)) {
                        byte[] bytes = StreamRead(fs, ref offset, 4);
                        float  value = BitConverter.ToSingle(bytes, 0);
                        info.SetValue(dataObj, value);
                    }
                    else if (info.FieldType == typeof(bool)) {
                        byte[] bytes = StreamRead(fs, ref offset, 1);
                        bool   value = BitConverter.ToBoolean(bytes, 0);
                        info.SetValue(dataObj, value);
                    }
                    else if (info.FieldType == typeof(string)) {
                        byte[] bytes      = StreamRead(fs, ref offset, 4); // 長(zhǎng)度
                        int    len        = BitConverter.ToInt32(bytes, 0);
                        byte[] valueBytes = StreamRead(fs, ref offset, len); // 內(nèi)容
                        string value      = Encoding.UTF8.GetString(valueBytes);
                        info.SetValue(dataObj, value);
                    }
                }

                // 添加對(duì)象到容器中
                FieldInfo  dicInfo  = containerType.GetField("dataDic");   // 字典字段信息
                object     dicObj   = dicInfo.GetValue(container);         // 獲取字典對(duì)象
                FieldInfo  keyInfo  = classType.GetField(keyName);         // 主鍵字段信息
                object     keyValue = keyInfo.GetValue(dataObj);           // 獲取主鍵對(duì)象
                MethodInfo mInfo    = dicObj.GetType().GetMethod("Add");   // Add 方法信息
                mInfo?.Invoke(dicObj, new object[] { keyValue, dataObj }); // 執(zhí)行 Add 方法
            }

            // 記錄表的內(nèi)容
            tableDic.Add(typeof(T).Name, container);
        }
    }

    /// <summary>
    /// 獲取表
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <returns></returns>
    public T GetTable<T>() where T : class {
        string tableName = typeof(T).Name;
        if (tableDic.TryGetValue(tableName, out object value)) {
            return value as T;
        }
        return null;
    }

    /// <summary>
    /// 讀取對(duì)應(yīng)長(zhǎng)度的字節(jié)流,offset 會(huì)進(jìn)行更新
    /// </summary>
    /// <param name="stream"></param>
    /// <param name="offset"></param>
    /// <param name="count"></param>
    /// <returns></returns>
    public byte[] StreamRead(Stream stream, ref int offset, int count) {
        byte[] bytes = new byte[count];
        offset = stream.Read(bytes, 0, count);
        return bytes;
    }

    /// <summary>
    /// 存儲(chǔ)二進(jìn)制數(shù)據(jù)
    /// </summary>
    /// <param name="obj"></param>
    /// <param name="filename"></param>
    public void Save(object obj, string filename) {
        // 如果文件夾不存在,則創(chuàng)建
        if (!Directory.Exists(SAVE_PATH)) {
            Directory.CreateDirectory(SAVE_PATH);
        }

        using (FileStream fs = new FileStream(SAVE_PATH + filename, FileMode.OpenOrCreate, FileAccess.Write)) {
            BinaryFormatter bf = new BinaryFormatter();
            bf.Serialize(fs, obj);
            fs.Close();
        }
    }

    /// <summary>
    /// 讀取二進(jìn)制數(shù)據(jù)轉(zhuǎn)換為對(duì)象
    /// </summary>
    /// <param name="filename"></param>
    /// <typeparam name="T"></typeparam>
    /// <returns></returns>
    public T Load<T>(string filename) where T : class {
        // 如果文件不存在,則返回泛型對(duì)象的默認(rèn)值
        if (!File.Exists(SAVE_PATH + filename)) {
            return default(T);
        }

        T obj = null;
        using (FileStream fs = new FileStream(SAVE_PATH + filename, FileMode.Open, FileAccess.Read)) {
            BinaryFormatter bf = new BinaryFormatter();
            obj = bf.Deserialize(fs) as T;
            fs.Close();
        }

        return obj;
    }
}

(三)演示步驟

1 ExcelTool

? 在 “BinaryDataMgr.cs” 中的 EXCEL_PATH 下存放數(shù)據(jù)表 “PlayerInfo.xlsx”,其內(nèi)容如下:

圖1 PlayerInfo.xlsx內(nèi)容

? 點(diǎn)擊菜單欄的 GameTool -> GenerateExcel,將在 DATA_CLASS_PATHDATA_CONTAINER_PATH 路徑下分別生成數(shù)據(jù)信息腳本和容器腳本:

圖2 生成數(shù)據(jù)信息和容器腳本

2 BinaryMgr

? 參考如下代碼:

  1. 存儲(chǔ)數(shù)據(jù)
Test t = new Test();
t.i = 985;
t.str = "歡迎你";

print(Application.persistentDataPath);
BinaryDataMgr.Instance.Save(t, "哈哈哈");
  1. 獲取數(shù)據(jù)
Test t = BinaryDataMgr.Instance.Load<Test>("哈哈哈");

? 存儲(chǔ)位置可修改 “BinaryDataMgr.cs” 中的 DATA_BINARY_PATH 路徑。

? 具體使用參考代碼注釋。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-467606.html

到了這里,關(guān)于2023-05-29 Unity 2進(jìn)制5——Excel配置表工具的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶(hù)投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • UNITY--讀取Excel的幾種方式

    UNITY--讀取Excel的幾種方式

    目錄 一.DLL插件讀取 1.1.Excel存放位置 1.2.使用示例 1.3.Excel格式 ?1.4.輸出顯示? 1.5.所需插件 二.Excel轉(zhuǎn)成Asset文件,再進(jìn)行讀取 2.1Excel文件存放位置 2.2 編輯模式生成Asset文件,并保存到指定位置? 2.3創(chuàng)建ExcelRead腳本,讀取Excel內(nèi)容 2.4 創(chuàng)建數(shù)據(jù)存儲(chǔ)腳本 2.5? 編輯器生成Asset 與屬

    2024年01月20日
    瀏覽(44)
  • 【Unity】用Excel庫(kù)讀取Excel表格(.xlsx或者.xls)

    【Unity】用Excel庫(kù)讀取Excel表格(.xlsx或者.xls)

    首先需要下載解析的庫(kù)??EPPlus,? Excel,? ICSharpCode.SharpZipLib? ? 下載鏈接: https://download.csdn.net/download/weixin_46472622/87238048 使用方法 我的Excel 表格是這樣的,每一列有一個(gè) 我用一個(gè)結(jié)構(gòu)體對(duì)象來(lái)表示 讀取的方法 ?全部代碼,以及調(diào)用: 如果是打包PC端的exe,需要將編輯

    2024年02月12日
    瀏覽(30)
  • Unity3D操作數(shù)據(jù)之Excel表操作(創(chuàng)建、讀取、寫(xiě)入、修改)

    Unity3D操作數(shù)據(jù)之Excel表操作(創(chuàng)建、讀取、寫(xiě)入、修改)

    叨嘮兩句: 首先使用Excel需要 導(dǎo)入插件 ,其次在 程序運(yùn)行 期間不要打開(kāi)對(duì)應(yīng)的Excel文件 其次相對(duì)于一些程序使用Excel比使用數(shù)據(jù)庫(kù)更具有優(yōu)勢(shì) 讀取主要使用 Epplus 插件,后續(xù)會(huì)推出關(guān)于Epplus的 AP I講解 讀取Excel文件,需要導(dǎo)入一些dll文件,才能進(jìn)行操作Excel數(shù)據(jù): 如果打包

    2024年02月05日
    瀏覽(28)
  • 2023-05-11:給你一個(gè) m x n 的二進(jìn)制矩陣 grid, 每個(gè)格子要么為 0 (空)要么為 1 (被占據(jù)), 給你郵票的尺寸為 stampHeight x stampWidth。 我們想將

    2023-05-11:給你一個(gè) m x n 的二進(jìn)制矩陣 grid, 每個(gè)格子要么為 0 (空)要么為 1 (被占據(jù)), 給你郵票的尺寸為 stampHeight x stampWidth。 我們想將

    2023-05-11:給你一個(gè) m x n 的二進(jìn)制矩陣 grid, 每個(gè)格子要么為 0 (空)要么為 1 (被占據(jù)), 給你郵票的尺寸為 stampHeight x stampWidth。 我們想將郵票貼進(jìn)二進(jìn)制矩陣中,且滿(mǎn)足以下 限制 和 要求 : 覆蓋所有空格子,不覆蓋任何被占據(jù)的格子, 可以放入任意數(shù)目的郵票,郵票

    2024年02月09日
    瀏覽(20)
  • 前端使用 xlsx.js 工具讀取 excel 遇到時(shí)間日期少 43 秒的解決辦法

    在使用 xlsx 讀取 excel 的時(shí)間格式的數(shù)據(jù)時(shí),如 ‘2023-11-30’,‘2023/11/30’ ,默認(rèn)會(huì)讀取一串?dāng)?shù)字字符串,如:‘45260’,此時(shí)需要在 read 的時(shí)候傳入一個(gè)配置項(xiàng): 此時(shí)拿到的是標(biāo)準(zhǔn)的時(shí)間格式 :‘Wed Nov 29 2023 23:59:17 GMT+0800(中國(guó)標(biāo)準(zhǔn)時(shí)間)’ ,這個(gè)時(shí)間格式是帶時(shí)區(qū)的,有沒(méi)

    2024年02月04日
    瀏覽(24)
  • 【Linux】Ubuntu20.04版本配置pytorch環(huán)境2023.09.05【教程】

    【Linux】Ubuntu20.04版本配置pytorch環(huán)境2023.09.05【教程】

    首先進(jìn)入Anaconda官網(wǎng)下載linux版本的安裝文件 Anaconda3-2023.07-2-Linux-x86_64.sh ,進(jìn)入安裝文件路徑,運(yùn)行下面的腳本進(jìn)行安裝 安裝需要閱讀用戶(hù)協(xié)議,一直按 enter 就行了,到當(dāng)前頁(yè)面時(shí)需要輸出 yes 進(jìn)行確認(rèn)即可開(kāi)始安裝。 然后按照提示進(jìn)行操作即可完成安裝。 Anaconda基本環(huán)境管

    2024年02月09日
    瀏覽(31)
  • 2023-05-07:給你一個(gè)大小為 n x n 二進(jìn)制矩陣 grid 。最多 只能將一格 0 變成 1 。 返回執(zhí)行此操作后,grid 中最大的島嶼面積是多少? 島嶼 由一組上、下、左、右四個(gè)方向相

    2023-05-07:給你一個(gè)大小為 n x n 二進(jìn)制矩陣 grid 。最多 只能將一格 0 變成 1 。 返回執(zhí)行此操作后,grid 中最大的島嶼面積是多少? 島嶼 由一組上、下、左、右四個(gè)方向相

    2023-05-07:給你一個(gè)大小為 n x n 二進(jìn)制矩陣 grid 。最多 只能將一格 0 變成 1 。 返回執(zhí)行此操作后,grid 中最大的島嶼面積是多少? 島嶼 由一組上、下、左、右四個(gè)方向相連的 1 形成。 輸入: grid = [[1, 0], [0, 1]]。 輸出: 3。 來(lái)自亞馬遜、谷歌、微軟、Facebook、Bloomberg。 答案202

    2024年02月11日
    瀏覽(23)
  • 【Unity 框架】QFramework v1.0 使用指南 工具篇:05. ResKit 資源管理&開(kāi)發(fā)解決方案 | Unity 游戲框架 | Unity 游戲開(kāi)發(fā) | Unity 獨(dú)立游戲

    【Unity 框架】QFramework v1.0 使用指南 工具篇:05. ResKit 資源管理&開(kāi)發(fā)解決方案 | Unity 游戲框架 | Unity 游戲開(kāi)發(fā) | Unity 獨(dú)立游戲

    Res Kit,是資源管理快速開(kāi)發(fā)解決方案 特性如下: 可以使用一個(gè) API 從 dataPath、Resources、StreammingAssetPath、PersistentDataPath、網(wǎng)絡(luò)等地方加載資源。 基于引用計(jì)數(shù),簡(jiǎn)化資源加載和卸載。 擁抱游戲開(kāi)發(fā)流程中的不同階段 開(kāi)發(fā)階段不用打 AB 直接從 dataPath 加載。 測(cè)試階段支持只需打

    2024年02月01日
    瀏覽(58)
  • 二進(jìn)制安裝Kubernetes(k8s)v1.29.2

    https://github.com/cby-chen/Kubernetes 開(kāi)源不易,幫忙點(diǎn)個(gè)star,謝謝了 kubernetes(k8s)二進(jìn)制高可用安裝部署,支持IPv4+IPv6雙棧。 我使用IPV6的目的是在公網(wǎng)進(jìn)行訪問(wèn),所以我配置了IPV6靜態(tài)地址。 若您沒(méi)有IPV6環(huán)境,或者不想使用IPv6,不對(duì)主機(jī)進(jìn)行配置IPv6地址即可。 不配置IPV6,不影

    2024年02月19日
    瀏覽(20)
  • 【我們一起60天準(zhǔn)備考研算法面試(大全)-第二十九天 29/60】【二進(jìn)制】

    【我們一起60天準(zhǔn)備考研算法面試(大全)-第二十九天 29/60】【二進(jìn)制】

    專(zhuān)注 效率 記憶 預(yù)習(xí) 筆記 復(fù)習(xí) 做題 歡迎觀看我的博客,如有問(wèn)題交流,歡迎評(píng)論區(qū)留言,一定盡快回復(fù)?。ù蠹铱梢匀タ次业膶?zhuān)欄,是所有文章的目錄) 文章字體風(fēng)格: 紅色文字表示:重難點(diǎn)★? 藍(lán)色文字表示:思路以及想法★? 如果大家覺(jué)得有幫助的話,感謝大家?guī)?/p>

    2024年02月15日
    瀏覽(16)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包