Android Studio工程的目录下都会有一个gradlew.bat,只要配置好app下的build.gradle,使用这个批处理可以快速编译生成apk,编写自动化生成工具等。
使用unity导出android工程编译apk为例,如果全部手动操作是个繁琐的过程,使用这个gradlew.bat可以免去许多麻烦操作。先配置好build.gradle,主要配置signingConfigs和buildTypes,如下例子:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.dfddf.dfddf.dfdfd"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
debug {
storeFile file('dsdsds.jks')
storePassword "sdsds"
keyAlias "sdsds"
keyPassword "sdsds"
}
release {
storeFile file('dsdsds.jks')
storePassword "sdsds"
keyAlias "sdsds"
keyPassword "sdsds"
}
}
buildTypes {
release {
minifyEnabled false
zipAlignEnabled false
shrinkResources false
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
lintOptions {
abortOnError false
}
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation files('libs/fastjson-1.1.52.android.jar')
implementation files('libs/jpush-android-2.0.5.jar')
implementation files('libs/SaaS_GameAnalytics_Android_SDK_V4.0.13.jar')
implementation files('libs/unity-classes.jar')
implementation files('libs/android-support-v7-recyclerview.jar')
implementation(name:'NoxSDK-3.6',ext:'aar')
}
从unity导出android工程,还有各种文件的复制删除操作等可以直接C#实现:
using UnityEngine;
using System.Collections;
using UnityEditor;
using System.IO;
using System.Xml;
using System.Text;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System;
public class SmallTools
{
[DllImport("user32.dll")]
public static extern void SwitchToThisWindow(IntPtr hWnd, bool fAltTab);
[MenuItem("Tools/SmallTools/BuildAndroidProject")]
static void BuildAndroidProject()
{
try
{
string xmlVersion = @"E:\xukong_en\GameClient_AssetBundles";
DirectoryInfo dInfo = Directory.CreateDirectory(xmlVersion);
FileInfo[] fInfos = dInfo.GetFiles();
for (int i = 0, j = fInfos.Length; i < j; i++)
{
if (fInfos[i].Name.StartsWith("GameResourceVersion"))
{
xmlVersion += (@"\" + fInfos[i].Name);
}
}
XmlDocument xml = new XmlDocument();
xml.Load(xmlVersion);
XmlNode xNode = xml.SelectSingleNode("ResourceVersionInfo");
string bigVersion = xNode.Attributes.GetNamedItem("ApplicableGameVersion").Value;
string smallVersion = xNode.Attributes.GetNamedItem("LatestInternalResourceVersion").Value;
bigVersion = bigVersion.Replace(".", "_");
string curVersion = bigVersion + "_" + smallVersion;
string resoucesPath = string.Format(@"E:\xukong_en\GameClient_AssetBundles\Packed\{0}\android", curVersion);
if (!Directory.Exists(resoucesPath))
{
Debug.LogError(string.Format("路径{0}不存在", resoucesPath));
return;
}
EditorUtility.DisplayProgressBar("复制资源", "正在复制0%", 0);
string androidPro = @"E:\xukong_en\GameClient_Android\Genesis";
DirectoryOperate(androidPro,true,false);
string sAssets = @"E:\xukong_en\Assets\StreamingAssets";
DirectoryOperate(sAssets);
dInfo = Directory.CreateDirectory(resoucesPath);
fInfos = dInfo.GetFiles("*", SearchOption.AllDirectories);
string copyToPath = @"E:\xukong_en\Assets\StreamingAssets\android";
for (int i = 0, j = fInfos.Length; i < j; i++)
{
float process = (float)i / j;
EditorUtility.DisplayProgressBar("复制资源", string.Format("正在复制{0}%", process * 100), process);
string file = fInfos[i].FullName.Replace(resoucesPath, copyToPath);
string fullPath = Path.GetDirectoryName(file);
if (!Directory.Exists(fullPath))
{
Directory.CreateDirectory(fullPath);
}
File.Copy(fInfos[i].FullName, file, true);
}
EditorUtility.ClearProgressBar();
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
string err = BuildPipeline.BuildPlayer(new string[] { "Assets/Launch.unity" }, "E:/xukong_en/GameClient_Android", BuildTarget.Android, BuildOptions.AcceptExternalModificationsToPlayer);
if (string.IsNullOrEmpty(err))
{
//---------------------拷贝到eclipse android工程
EditorUtility.DisplayProgressBar("拷贝到AndroidStudio工程", "正在拷贝0%", 0);
string eclipseProj = @"D:\androidStudio-workspace\xukong_dingliangame\app\src\main\assets";//@"D:\eclipse-workspace2\XuKong_DingLian\assets";
DirectoryOperate(eclipseProj);
string genesisPath = @"E:\xukong_en\GameClient_Android\Genesis\assets";
dInfo = Directory.CreateDirectory(genesisPath);
fInfos = dInfo.GetFiles("*", SearchOption.AllDirectories);
for (int i = 0, j = fInfos.Length; i < j; i++)
{
string file = fInfos[i].FullName.Replace(genesisPath, eclipseProj);
string fullPath = Path.GetDirectoryName(file);
if (!Directory.Exists(fullPath))
{
Directory.CreateDirectory(fullPath);
}
File.Copy(fInfos[i].FullName, file, true);
float proc = (float)i / j;
EditorUtility.DisplayProgressBar("拷贝到AndroidStudio工程", string.Format("正在拷贝{0}%", proc * 100), proc);
}
EditorUtility.ClearProgressBar();
EditorUtility.DisplayDialog("导出android工程", "导出完成,点击OK开始生成apk", "OK");
GradlewBatBuild();
//string exeName = @"D:\adt-bundle-windows-x86_64-20140702\eclipse\eclipse.exe";
//System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("eclipse");
//if(processes.Length <= 0)
// System.Diagnostics.Process.Start(exeName);
//else
//{
// IntPtr handle = processes[0].MainWindowHandle;
// SwitchToThisWindow(handle, true); // 激活,显示在最前
//}
}
}
catch (System.Exception e)
{
Debug.LogError(e);
}
}
static void DirectoryOperate(string path,bool delete = true,bool create = true)
{
try
{
if (delete && Directory.Exists(path))
Directory.Delete(path, true);
if (create)
Directory.CreateDirectory(path);
}
catch(System.Exception e)
{
Debug.LogError(e);
}
}
//[MenuItem("Tools/SmallTools/GradlewBatBuild")]
static void GradlewBatBuild()
{
string path = @"D:\androidStudio-workspace\xukong_dingliangame\app\build\outputs\apk\release";
DirectoryOperate(path);
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.WorkingDirectory = @"D:\androidStudio-workspace\xukong_dingliangame\";
proc.StartInfo.FileName = "gradlew.bat";
proc.StartInfo.Arguments = "assembleRelease";
proc.Start();
proc.WaitForExit();
proc.Close();
proc.Dispose();
proc = System.Diagnostics.Process.Start("explorer.exe", path);
proc.WaitForExit();
proc.Close();
proc.Dispose();
}
[MenuItem("Tools/SmallTools/SetUiTexure")]
static void SetUiTexure()
{
string path = @"Assets/Main/UI/UITextures";
string path_cn = @"Assets\Main\Localization\ChineseSimplified\UI\UITextures";
string path_tw = @"Assets\Main\Localization\ChineseTraditional\UI\UITextures";
string path_en = @"Assets\Main\Localization\English\UI\UITextures";
string[] allPaths = AssetDatabase.GetAllAssetPaths();
EditorUtility.DisplayProgressBar("设置ui贴图", "正在设置0%", 0);
for (int i = 0, j = allPaths.Length; i < j; i++)
{
float process = (float)i / j;
EditorUtility.DisplayProgressBar("设置ui贴图", string.Format("正在设置{0}%", process * 100), process);
if (!allPaths[i].Contains(path) &&
!allPaths[i].Contains(path_cn) &&
!allPaths[i].Contains(path_tw) &&
!allPaths[i].Contains(path_en))
continue;
string ext = System.IO.Path.GetExtension(allPaths[i]);
if (ext != ".png" && ext != ".jpg")
continue;
TextureImporter aImp = TextureImporter.GetAtPath(allPaths[i]) as TextureImporter;
aImp.textureType = TextureImporterType.Advanced;
aImp.grayscaleToAlpha = false;
aImp.alphaIsTransparency = true;
aImp.isReadable = false;
aImp.mipmapEnabled = false;
aImp.wrapMode = TextureWrapMode.Clamp;
aImp.SaveAndReimport();
}
EditorUtility.ClearProgressBar();
EditorUtility.DisplayDialog("设置ui贴图", "设置完成", "OK");
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
[MenuItem("Tools/SmallTools/CheckAssetGuid")]
static void CheckAssetGuid()
{
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(@"E:\xukong_en\Assets\GameFramework\Editor\AssetBundleCollection.xml");
XmlNode xmlRoot = xmlDocument.SelectSingleNode("UnityGameFramework");
xmlRoot = xmlRoot.SelectSingleNode("AssetBundleCollection");
xmlRoot = xmlRoot.SelectSingleNode("Assets");
XmlNodeList xmlNodeDictionaryList = xmlRoot.ChildNodes;
EditorUtility.DisplayProgressBar("检查资源guid", "正在检查0%", 0);
for (int i = 0, j = xmlNodeDictionaryList.Count; i < j; i++)
{
float process = (float)i / j;
EditorUtility.DisplayProgressBar("检查资源guid", string.Format("正在检查{0}%", process * 100), process);
XmlNode xmlNodeString = xmlNodeDictionaryList.Item(i);
XmlNode bName = xmlNodeString.Attributes.GetNamedItem("AssetBundleName");
string uid = xmlNodeString.Attributes.GetNamedItem("Guid").Value;
string aPath = AssetDatabase.GUIDToAssetPath(uid);
if(string.IsNullOrEmpty(aPath))
{
Debug.LogError(string.Format("===============>guid 失效guid={0}uid,AssetBundle {1}",uid, bName.Value));
}
else
{
Debug.LogError(aPath);
}
}
EditorUtility.ClearProgressBar();
EditorUtility.DisplayDialog("检查资源guid", "检查完成", "OK");
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
[MenuItem("Tools/SmallTools/UpdateAssetBundleCollection")]
static void UpdateAssetBundleCollection()
{
string xmlDocumentPath = @"E:\xukong_en\Assets\GameFramework\Editor\AssetBundleCollection.xml";
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(xmlDocumentPath);
XmlNode xmlRoot = xmlDocument.SelectSingleNode("UnityGameFramework");
xmlRoot = xmlRoot.SelectSingleNode("AssetBundleCollection");
xmlRoot = xmlRoot.SelectSingleNode("Assets");
XmlNodeList xmlNodeDictionaryList = xmlRoot.ChildNodes;
List<string> current = new List<string>();
List<XmlNode> removeNode = new List<XmlNode>();
string[] allAssets = AssetDatabase.GetAllAssetPaths();
EditorUtility.DisplayProgressBar("分析AssetBundleCollection.xml", "正在分析0%", 0);
for (int i = 0, j = xmlNodeDictionaryList.Count; i < j; i++)
{
float process = (float)i / j;
EditorUtility.DisplayProgressBar("分析AssetBundleCollection.xml", string.Format("正在分析{0}%", process * 100), process);
XmlNode xmlNodeString = xmlNodeDictionaryList.Item(i);
string uid = xmlNodeString.Attributes.GetNamedItem("Guid").Value;
string aPath = AssetDatabase.GUIDToAssetPath(uid);
if (string.IsNullOrEmpty(uid) || !File.Exists(@"E:\xukong_en\" + aPath.Replace("/",@"\")))
{
removeNode.Add(xmlNodeString);
continue;
}
current.Add(uid);
}
EditorUtility.DisplayProgressBar("删除无用资源", "正在删除0%", 0);
for (int i = 0, j = removeNode.Count; i < j; i++)
{
float process = (float)i / j;
EditorUtility.DisplayProgressBar("删除无用资源", string.Format("正在删除{0}%", process * 100), process);
xmlRoot.RemoveChild(removeNode[i]);
}
EditorUtility.DisplayProgressBar("添加新增资源", "正在添加0%", 0);
for (int i = 0,j = allAssets.Length;i<j;i++)
{
float process = (float)i / j;
EditorUtility.DisplayProgressBar("添加新增资源", string.Format("正在添加{0}%", process * 100), process);
string guid = AssetDatabase.AssetPathToGUID(allAssets[i]);
if (current.Contains(guid))
continue;
XmlNode xNode = xmlRoot.ChildNodes.Item(0).Clone();
xNode.Attributes.GetNamedItem("Guid").Value = guid;
XmlAttribute xAttr = xNode.Attributes.GetNamedItem("AssetBundleName") as XmlAttribute;
if(null != xAttr)
xNode.Attributes.Remove(xAttr);
xmlRoot.AppendChild(xNode);
}
xmlDocument.Save(xmlDocumentPath);
EditorUtility.ClearProgressBar();
EditorUtility.DisplayDialog("更新AssetBundleCollection.xml", "更新完成", "OK");
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
[MenuItem("Tools/SmallTools/SetAssetVariant")]
static void SetAssetVariant()
{
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(@"E:\xukong_en\Assets\GameFramework\Editor\AssetBundleCollection.xml");
XmlNode xmlRoot = xmlDocument.SelectSingleNode("UnityGameFramework");
xmlRoot = xmlRoot.SelectSingleNode("AssetBundleCollection");
xmlRoot = xmlRoot.SelectSingleNode("Assets");
XmlNodeList xmlNodeDictionaryList = xmlRoot.ChildNodes;
EditorUtility.DisplayProgressBar("设置资源变体", "正在设置0%", 0);
for (int i = 0, j = xmlNodeDictionaryList.Count; i < j; i++)
{
float process = (float)i / j;
EditorUtility.DisplayProgressBar("设置资源变体", string.Format("正在设置{0}%", process * 100), process);
XmlNode xmlNodeString = xmlNodeDictionaryList.Item(i);
string uid = xmlNodeString.Attributes.GetNamedItem("Guid").Value;
string aPath = AssetDatabase.GUIDToAssetPath(uid);
AssetImporter aImp = AssetImporter.GetAtPath(aPath);
if(null == aImp)
{
Debug.LogError("=============>>导入资源失败:" + aPath);
continue;
}
XmlNode variant = xmlNodeString.Attributes.GetNamedItem("AssetBundleVariant");
XmlNode bName = xmlNodeString.Attributes.GetNamedItem("AssetBundleName");
try
{
if (null == variant)
{
aImp.assetBundleName = bName.Value;
aImp.assetBundleVariant = null;
}
else
{
aImp.assetBundleName = bName.Value;
aImp.assetBundleVariant = variant.Value;
}
aImp.SaveAndReimport();
}
catch(System.Exception e)
{
Debug.LogError("path:" + aPath);
Debug.LogError(e);
}
}
EditorUtility.ClearProgressBar();
EditorUtility.DisplayDialog("设置资源变体", "设置完成", "OK");
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
//[MenuItem("Tools/SmallTools/TestSerializedObject")]
//static void TestSerializedObject()
//{
// Object obj = Selection.activeObject;
// if (null == obj) return;
// string path = AssetDatabase.GetAssetPath(obj);
// if (System.IO.Path.GetExtension(path) != ".prefab")
// return;
// GameObject go = obj as GameObject;
// UILabel[] labels = go.GetComponentsInChildren<UILabel>(true);
// for(int i = 0,j =labels.Length;i < j;i++)
// {
// SerializedObject sObj = new SerializedObject(labels[i]);
// SerializedProperty sp = sObj.FindProperty("mFontSize");
// sObj.Update();
// sp.intValue -= 2;
// Debug.LogError(sp.intValue);
// Debug.LogError(sObj.ApplyModifiedProperties());
// }
// AssetDatabase.SaveAssets();
// AssetDatabase.Refresh();
// //Object prefabObj = PrefabUtility.GetPrefabObject(obj);
// //SerializedObject sObj = new SerializedObject(prefabObj);
// //sObj.
//}
[MenuItem("Tools/SmallTools/ChangeAtlases")]
static void ChangeAtlases()
{
UnityEngine.Object atlObj = AssetDatabase.LoadAssetAtPath("Assets/Main/Localization/English/UI/Atlases/Graphic.prefab", typeof(UnityEngine.Object));
if (null == atlObj)
{
Debug.LogError("无法加载图集资源");
return;
}
string path = @"Assets/Main/Prefabs/UI";
string[] allPaths = AssetDatabase.GetAllAssetPaths();
EditorUtility.DisplayProgressBar("设置图集", "正在设置0%", 0);
for (int i = 0, j = allPaths.Length; i < j; i++)
{
float process = (float)i / j;
EditorUtility.DisplayProgressBar("设置图集", string.Format("正在设置{0}%", process * 100), process);
if (!allPaths[i].Contains(path))
continue;
if (System.IO.Path.GetExtension(allPaths[i]) != ".prefab")
continue;
GameObject go = AssetDatabase.LoadAssetAtPath(allPaths[i], typeof(UnityEngine.Object)) as GameObject;
if (null == go)
continue;
UISprite[] sprites = go.GetComponentsInChildren<UISprite>(true);
for (int a = 0, b = sprites.Length; a < b; a++)
{
if (null == sprites[a].atlas ||
string.IsNullOrEmpty(sprites[a].atlas.name) ||
"Graphic" != sprites[a].atlas.name)
continue;
SerializedObject sObj = new SerializedObject(sprites[a]);
SerializedProperty sp = sObj.FindProperty("mAtlas");
if (null == sp)
continue;
sObj.Update();
sp.objectReferenceValue = atlObj;
Debug.LogError(sObj.ApplyModifiedProperties());
}
}
EditorUtility.ClearProgressBar();
EditorUtility.DisplayDialog("设置图集", "设置完成", "OK");
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
[MenuItem("Tools/SmallTools/ChangeFontSize")]
static void ChangeFontSize()
{
UnityEngine.Object fontObj = AssetDatabase.LoadAssetAtPath("Assets/Main/Localization/English/Fonts/MainFont.ttf", typeof(UnityEngine.Object));
if (null == fontObj)
{
Debug.LogError("无法加载字体资源");
return;
}
string path = @"Assets/Main/Prefabs/UI";
string[] allPaths = AssetDatabase.GetAllAssetPaths();
EditorUtility.DisplayProgressBar("设置ui字体大小","正在设置0%",0);
for(int i = 0,j = allPaths.Length;i<j;i++)
{
float process = (float)i / j;
EditorUtility.DisplayProgressBar("设置ui字体大小", string.Format("正在设置{0}%", process * 100), process);
if (!allPaths[i].Contains(path))
continue;
if (System.IO.Path.GetExtension(allPaths[i]) != ".prefab")
continue;
GameObject go = AssetDatabase.LoadAssetAtPath(allPaths[i],typeof(UnityEngine.Object)) as GameObject;
if (null == go)
continue;
UILabel[] labels = go.GetComponentsInChildren<UILabel>(true);
for(int a = 0,b = labels.Length;a < b;a++)
{
SerializedObject sObj = new SerializedObject(labels[a]);
SerializedProperty sp = sObj.FindProperty("mTrueTypeFont");
//SerializedProperty sp = sObj.FindProperty("mOverflow");
if (null == sp)
continue;
sObj.Update();
//SerializedProperty sp = sObj.FindProperty("mFontSize");
//sp.intValue -= 2;
//sp.intValue = (int)UILabel.Overflow.ResizeHeight;
sp.objectReferenceValue = fontObj;
sp = sObj.FindProperty("mFont");
sp.objectReferenceValue = null;
Debug.LogError(sObj.ApplyModifiedProperties());
//Debug.LogError(go.name + " // " + labels[a].name + " // " + sObj.ApplyModifiedProperties());
}
}
EditorUtility.ClearProgressBar();
EditorUtility.DisplayDialog("设置ui字体大小", "设置完成","OK");
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
[MenuItem("Tools/SmallTools/DoDefaultDictionary2xml")]
static void DoDefaultDictionary2xml()
{
Dictionary<string, string> dic = new Dictionary<string, string>();
using (FileStream fs = File.Open(@"E:\gameclient\Assets\Main\Publisher\DefaultDictionary.txt", FileMode.Open))
{
StreamReader sr = new StreamReader(fs, Encoding.Unicode);
string lineText = null;
while (!string.IsNullOrEmpty(lineText = sr.ReadLine()))
{
if (lineText.StartsWith("#"))
continue;
string[] texts = lineText.Split('\t');
if(texts.Length == 4)
{
dic.Add(texts[1], texts[3]);
}
else
{
Debug.LogError("Error: " + lineText);
}
}
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(@"E:\gameclient\Assets\Main\Publisher\DefaultDictionary.xml");
XmlNode xmlRoot = xmlDocument.SelectSingleNode("Dictionaries");
XmlNodeList xmlNodeDictionaryList = xmlRoot.ChildNodes;
EditorUtility.DisplayProgressBar("转表", "已完成0%", 0);
for (int i = 0,j = xmlNodeDictionaryList.Count; i < j; i++)
{
EditorUtility.DisplayProgressBar("转表", "已完成0%", (float)i/j);
if (xmlNodeDictionaryList[i].Attributes.GetNamedItem("Language").Value != "English")
continue;
XmlNodeList keyValues = xmlNodeDictionaryList[i].ChildNodes;
string key = null;
for(int a = 0,b = keyValues.Count;a < b;a++)
{
key = keyValues[a].Attributes.GetNamedItem("Key").Value;
if(!dic.ContainsKey(key))
{
Debug.LogError("Error: dic have no key " + key);
continue;
}
keyValues[a].Attributes.GetNamedItem("Value").Value = dic[key];
}
}
EditorUtility.ClearProgressBar();
EditorUtility.DisplayDialog("转表","转表完成","好的~退下");
xmlDocument.Save(@"E:\gameclient\Assets\Main\Publisher\DefaultDictionary.xml");
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
}
[MenuItem("Tools/SmallTools/DefaultDictionary2txt")]
static void DoDefaultDictionary2txt()
{
UnityEngine.Object obj = Selection.activeObject;
string objPath = null;
if(null != obj)
{
objPath = AssetDatabase.GetAssetPath(obj);
}
if(null != objPath && Path.GetExtension(objPath) == ".xml")
{
TextAsset ta = AssetDatabase.LoadAssetAtPath(objPath,typeof(TextAsset)) as TextAsset;
if(null == ta)
{
return;
}
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(ta.text);
XmlNode xmlRoot = xmlDocument.SelectSingleNode("Dictionaries");
XmlNodeList xmlNodeDictionaryList = xmlRoot.ChildNodes;
using (FileStream fs = File.Create(Application.dataPath + objPath.Replace("Assets", "").Replace("xml", "txt")))
{
using (System.IO.StreamWriter sw = new StreamWriter(fs))
{
sw.WriteLine("#\t字典配置表");
sw.WriteLine("#\tKey\t\tValue");
sw.WriteLine("#\tstring\t\tstring");
sw.WriteLine("#\t字典主键\t策划备注\t字典内容,可使用转义符");
for (int i = 0; i < xmlNodeDictionaryList.Count; i++)
{
XmlNode xmlNode = xmlNodeDictionaryList.Item(i);
if (xmlNode.Name != "Dictionary")
{
continue;
}
XmlNodeList xmlNodeStringList = xmlNode.ChildNodes;
for (int j = 0; j < xmlNodeStringList.Count; j++)
{
XmlNode xmlNodeString = xmlNodeStringList.Item(j);
if (xmlNodeString.Name != "String")
{
continue;
}
string key = xmlNodeString.Attributes.GetNamedItem("Key").Value;
string value = xmlNodeString.Attributes.GetNamedItem("Value").Value;
//sw.WriteLine(" " + key + " " + value);
sw.WriteLine("\t" + key + "\t\t" + value);
}
}
}
}
}
}
//[MenuItem("Tools/SmallTools/PrintAssetsGuid")]
//static void PrintAssetsGuid()
//{
// UnityEngine.Object obj = Selection.activeObject;
// if (null == obj)
// return;
// string path = AssetDatabase.GetAssetPath(obj);
// string guid = AssetDatabase.AssetPathToGUID(path);
// Debug.LogError(string.Format("path: {0} guid: {1}",path,guid));
//}
}
unity打包资源包后,只需选择菜单BuildAndroidProject即可一键生成apk。