using UnityEngine;
using UnityEditor;
using System.IO;
public class Test : Editor
{
public static byte[] bytes;
/// <summary>
/// 在菜单栏创建窗口
/// </summary>
[MenuItem("Assets/读取内容")]
public static void Read()
{
// char vale;
//创建一个txt的文件,
// File.Create(Application.dataPath + "/bb.txt");
//读文件里的内容,转换成字节,文件要utf—8格式的
bytes = File.ReadAllBytes(Application.dataPath + "/bb.txt");
// for (int i = 0; i < bytes.Length; i++)
// {
// vale= (char)bytes[i];
// Debug.Log(vale);
// }
//刷新
AssetDatabase.Refresh();
}
[MenuItem("Assets/复制选中的文件")]
public static void InTxt()
{
//创建个文件在里面写字符
//File.WriteAllText(Application.dataPath+"/aaa.txt", "1555");
//选取的object这种内型的对象
UnityEngine.Object o= Selection.activeObject;
if (o == null)
{
Debug.Log("当前没有选择任何东西,取消复制");
return;
}
bytes = File.ReadAllBytes(Application.dataPath + "/"+o.name+".txt");
FileStream str= File.Create(Application.dataPath + "/" + "(nool)"+ o.name +".txt");
//开始复制你选中的文件
str.BeginWrite(bytes, 0, bytes.Length, null, null);
str.Close();
str.Dispose();
//刷新
AssetDatabase.Refresh();
}
}
using UnityEditor;
using System.IO;
public class Test : Editor
{
public static byte[] bytes;
/// <summary>
/// 在菜单栏创建窗口
/// </summary>
[MenuItem("Assets/读取内容")]
public static void Read()
{
// char vale;
//创建一个txt的文件,
// File.Create(Application.dataPath + "/bb.txt");
//读文件里的内容,转换成字节,文件要utf—8格式的
bytes = File.ReadAllBytes(Application.dataPath + "/bb.txt");
// for (int i = 0; i < bytes.Length; i++)
// {
// vale= (char)bytes[i];
// Debug.Log(vale);
// }
//刷新
AssetDatabase.Refresh();
}
[MenuItem("Assets/复制选中的文件")]
public static void InTxt()
{
//创建个文件在里面写字符
//File.WriteAllText(Application.dataPath+"/aaa.txt", "1555");
//选取的object这种内型的对象
UnityEngine.Object o= Selection.activeObject;
if (o == null)
{
Debug.Log("当前没有选择任何东西,取消复制");
return;
}
bytes = File.ReadAllBytes(Application.dataPath + "/"+o.name+".txt");
FileStream str= File.Create(Application.dataPath + "/" + "(nool)"+ o.name +".txt");
//开始复制你选中的文件
str.BeginWrite(bytes, 0, bytes.Length, null, null);
str.Close();
str.Dispose();
//刷新
AssetDatabase.Refresh();
}
}