static BridgeExport() { references = DirectoryBuilder.RegisterDirectory("references", new DirectoryStructure("References~")); build = DirectoryBuilder.RegisterDirectory("build", new DirectoryStructure("Build~")); configs = DirectoryBuilder.RegisterDirectory("configs", new DirectoryStructure("Configs")); TMP_BINDING_CACHE = build["BindingsCache"].FullPath; TMP_CODE_PATH = build["Temp"].FullPath; PROJECT_CODE_PATH = build["Project"].FullPath; }
static DirectoryUtil() { configs = DirectoryBuilder.RegisterDirectory("configs", new DirectoryStructure("Configs")); configs.AddReadme("## 存放配置文件"); configs.AddSubDirectory("ScriptableObject", "## 存放ScriptableObject类型的配置文件"); configs.AddSubDirectory("Text", "## 存放文本类型的配置文件"); configs.BuildDirectory(); }
private static void GeneratePluginStubDLL(UnityPlugin config) { if (!config.enable) { return; } if (references == null) { references = DirectoryBuilder.RegisterDirectory("references", new DirectoryStructure("References~")); } var sources = new List <string>() { config.stubPath.stubCSPath }; // Add refCS stub file var refCS = config.stubPath.stubRefCSPath; if (refCS != null && File.Exists(refCS)) { sources.Add(refCS); } var os = File.Create(config.stubPath.stubDLLPath); // var refs = UnityPluginUtil.GetLib(config, true, true); var refs = new List <string>() { references["Bridge"]["Bridge.dll"], UnityPluginUtil.GetUnityEngineStub().stubPath.stubDLLPath }; if (refs == null || refs.Count == 0) { return; } EmitResult result; try { result = DLLProc.BuildDLL(config.pluginName + "-stub", os, sources, config.defineMacros, refs, true); } finally { os.Close(); } if (result == null || !result.Success) { throw new Exception(); } }
public static string GetModelToolPath() { string toolDir = ""; WXConfig.commons = DirectoryBuilder.RegisterDirectory("commons", new DirectoryStructure("Common")); if (Application.platform == RuntimePlatform.WindowsEditor) { toolDir = commons["Tools"].GetFilePath("model.exe"); } else if (Application.platform == RuntimePlatform.OSXEditor) { toolDir = commons["Tools"].GetFilePath("Model_Mac"); } return(toolDir); }
public static DirectoryStructure RegisterDirectory(string name, DirectoryStructure directory) { if (!directories.ContainsKey(name)) { if (directories.Count > 0) { var d = directories.Values.FirstOrDefault(_d => _d.Root == directory.Root); if (d != null) { Debug.LogWarning("[Directory Builder]: " + directory.Root + " already added"); directories.Add(name, d); return(d); } } directories.Add(name, directory); return(directory); } return(directories[name]); }
/// <summary> /// 判断资源文件是否存在,返回False为任意一个文件不存在 /// </summary> /// <returns>Boolean</returns> private bool Precheck() { // DirectoryStructure Init if (build == null) { build = DirectoryBuilder.RegisterDirectory("build", new DirectoryStructure("Build~")); } if (references == null) { references = DirectoryBuilder.RegisterDirectory("references", new DirectoryStructure("References~")); } if (configs == null) { configs = DirectoryBuilder.RegisterDirectory("configs", new DirectoryStructure("Configs")); } // Check Files return(textResList.TrueForAll(res => CheckFileExist(configs, "Text", res)) && bridgeResList.TrueForAll(res => CheckFileExist(references, "Bridge", res)) && adaptorResList.TrueForAll(res => CheckFileExist(references, "Adaptor", res))); }
public static void GeneUnityStub(bool overwrite = true) { var unity = UnityPluginUtil.GetUnityEngineStub(); if (!overwrite && File.Exists(unity.stubPath.stubCSPath)) { Debug.LogWarning("UnityEngine Stub Exist."); return; } if (unity.stubConfig.generateStub) { // UnityStubBuilder.Build(unity.stubPath.stubCSPath); // 这里改用反射 // UnityStubBuilder.cs 需要被单独作为c#源文件放出,编DLL时不能耦合 // Type.GetType("WeChat.UnityStubBuilder").GetMethod("Build").Invoke(null, new object[] { unity.stubPath.stubCSPath }); // 这里改用回调,DLL里调用反射拿不到C#源文件里定义的类,有空再查 if (genUnityStubCallback != null) { genUnityStubCallback.Invoke(unity.stubPath.stubCSPath); } } // header var allRefContent = string.Format(topHeader, unity.pluginName); string content = ""; using (StreamReader sr = new StreamReader(unity.stubPath.stubCSPath)) { content = sr.ReadToEnd(); } if (content == null || content == "" || content.Length == 0) { return; } using (var sw = new StreamWriter(unity.stubPath.stubCSPath, false)) { sw.Write(allRefContent); sw.Write(content); } var sources = new List <string>() { unity.stubPath.stubCSPath }; var dir = new DirectoryInfo(Path.GetDirectoryName(unity.stubPath.stubDLLPath)); if (!dir.Exists) { dir.Create(); } var os = File.Create(unity.stubPath.stubDLLPath); if (references == null) { references = DirectoryBuilder.RegisterDirectory("references", new DirectoryStructure("References~")); } var refs = new List <string>() { references["Bridge"]["Bridge.dll"] }; EmitResult result; try { result = DLLProc.BuildDLL("UnityEngine-stub", os, sources, unity.defineMacros, refs, true); } finally { os.Close(); } if (result == null || !result.Success) { throw new Exception(); } Debug.Log("Generate Stub <UnityEngine>"); }
static PathUtil() { build = DirectoryBuilder.RegisterDirectory("build", new DirectoryStructure("Build~")); }
private bool CheckFileExist(DirectoryStructure structure, string subPath, string filePath) { // Debug.Log("fullpath: " + structure[subPath].GetFilePath(filePath) + " Exist: " + structure[subPath].Exists(filePath)); return(structure[subPath].Exists(filePath)); }
public SubDirWrapper(DirectoryStructure s) { this.structure = s; }