之前看过好多别人的关于这个问题的实现,自己看了很多的实现方式,感谢前辈提供的思路以及方法,现在自己总结归纳一下,写一下自己的解决方案。
首先需要将以下资源导入项目:
ExcelDataReader :http://exceldatareader.codeplex.com/;
导表工具的每次新加需要处理的excel就需要重新创建与之前处理excel类似的类,所以为了维护的便利,在类似脚本的创建上采取了自动化脚本生成,之后的维护中,只需要在指定目录下按照格式创建excel文件,然后在excel管理类中添加需要读取的excel名,在通过Editor创建的工具来生成或者修改,将读取的数据转化为Unity的asset文件(转成Json也行)。以下放下代码一段段来说把。
- 工具类
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.UI;
using System;
using System.IO;
public class UIEditorCreateMenu : EditorWindow
{
[MenuItem("工具/读表工具", false, 1)]
public static void ShowWindow()
{
UnityEngine.Debug.Log(string.Format("[{0}] 打开资源打包工具 persistentDataPath=[{1}]", DateTime.Now, Application.persistentDataPath));
UIEditorCreateMenu window = EditorWindow.GetWindow(typeof(UIEditorCreateMenu)) as UIEditorCreateMenu;