开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 15

lbzcode/UnityFun

forked from jzt/UnityFun
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (1)
master
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
项目仓库所选许可证以仓库主分支所使用许可证为准
master
分支 (1)
master
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (1)
master
UnityFun
/
Assets
/
Scripts
/
Editor
/
CSProjectFile.cs
UnityFun
/
Assets
/
Scripts
/
Editor
/
CSProjectFile.cs
CSProjectFile.cs 7.61 KB
一键复制 编辑 原始数据 按行查看 历史
陈勇星 提交于 2017年01月05日 17:16 +08:00 . 完成基础RPC功能和添加测试代码
using System.IO;
using System.Xml;
using UnityEngine;
using UnityEditor;
public class CSProjectFile
{
public string AssemblyName;
public string ProjectPath;
public string[] SrcList;
public CSProjectFile(string assemblyName, string projectPath, string[] srcList)
{
AssemblyName = assemblyName;
ProjectPath = projectPath;
SrcList = srcList;
}
public void GenerateCSProject(CSProjectFile csproj)
{
string csprojDir = Path.GetDirectoryName(csproj.ProjectPath);
if (!Directory.Exists(csprojDir))
{
Directory.CreateDirectory(csprojDir);
}
var doc = new XmlDocument();
doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", null));
var project = doc.CreateElement("Project");
project.SetAttribute("ToolsVersion", "4.0");
project.SetAttribute("DefaultTargets", "Build");
project.SetAttribute("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");
var propertyGroup = doc.CreateElement("PropertyGroup");
var configuration = doc.CreateElement("Configuration");
configuration.SetAttribute("Condition", " '$(Configuration)' == '' ");
configuration.InnerText = "Debug";
propertyGroup.AppendChild(configuration);
var platform = doc.CreateElement("Platform");
platform.SetAttribute("Condition", " '$(Platform)' == '' ");
platform.InnerText = "AnyCPU";
propertyGroup.AppendChild(platform);
var projectGuid = doc.CreateElement("ProjectGuid");
projectGuid.InnerText = "{05ABCACF-71A2-4C54-95F9-04BCF0C913F3}";
propertyGroup.AppendChild(projectGuid);
var outputType = doc.CreateElement("OutputType");
outputType.InnerText = "Library";
propertyGroup.AppendChild(outputType);
var assemblyName = doc.CreateElement("AssemblyName");
assemblyName.InnerText = csproj.AssemblyName;
propertyGroup.AppendChild(assemblyName);
var targetFrameworkIdentifier = doc.CreateElement("TargetFrameworkIdentifier");
targetFrameworkIdentifier.InnerText = ".NETFramework";
propertyGroup.AppendChild(targetFrameworkIdentifier);
var targetFrameworkVersion = doc.CreateElement("TargetFrameworkVersion");
targetFrameworkVersion.InnerText = "v3.5";
propertyGroup.AppendChild(targetFrameworkVersion);
project.AppendChild(propertyGroup);
project.AppendChild(GeneratePlatformPropertyGroup(doc, "Debug"));
project.AppendChild(GeneratePlatformPropertyGroup(doc, "Release"));
project.AppendChild(GenReferenceItemGroup(doc));
var itemGroup = doc.CreateElement("ItemGroup");
foreach (var src in csproj.SrcList)
{
var compile = doc.CreateElement("Compile");
compile.SetAttribute("Include", src);
itemGroup.AppendChild(compile);
}
project.AppendChild(itemGroup);
var import = doc.CreateElement("Import");
import.SetAttribute("Project", @"$(MSBuildToolsPath)\Microsoft.CSharp.targets");
project.AppendChild(import);
var target = doc.CreateElement("Target");
target.SetAttribute("Name", "AfterBuild");
var copy = doc.CreateElement("Copy");
copy.SetAttribute("SourceFiles", string.Format(@"$(OutputPath){0}.dll", AssemblyName));
copy.SetAttribute("DestinationFolder", string.Format(@"{0}\Assets\Plugins", System.Environment.CurrentDirectory));
copy.SetAttribute("ContinueOnError", "false");
target.AppendChild(copy);
project.AppendChild(target);
doc.AppendChild(project);
doc.Save(csproj.ProjectPath);
}
private static XmlElement GeneratePlatformPropertyGroup(XmlDocument doc, string mode)
{
var propertyGroup = doc.CreateElement("PropertyGroup");
propertyGroup.SetAttribute("Condition", " '$(Configuration)|$(Platform)' == '" + mode + "|AnyCPU' ");
var debugType = doc.CreateElement("DebugType");
debugType.InnerText = "pdbonly";
propertyGroup.AppendChild(debugType);
var optimize = doc.CreateElement("Optimize");
optimize.InnerText = "false";
propertyGroup.AppendChild(optimize);
var outputPath = doc.CreateElement("OutputPath");
outputPath.InnerText = string.Format(@"bin\{0}\", mode);
propertyGroup.AppendChild(outputPath);
var intermediateOutputPath = doc.CreateElement("IntermediateOutputPath");
intermediateOutputPath.InnerText = string.Format(@"obj\{0}\", mode);
propertyGroup.AppendChild(intermediateOutputPath);
var errorRepoert = doc.CreateElement("ErrorReport");
errorRepoert.InnerText = "prompt";
propertyGroup.AppendChild(errorRepoert);
var warningLevel = doc.CreateElement("WarningLevel");
warningLevel.InnerText = "4";
propertyGroup.AppendChild(warningLevel);
var defineStr =
"TRACE;ENABLE_PROFILER";
var defineConstants = doc.CreateElement("DefineConstants");
defineConstants.InnerText = string.Format("{0};{1}", mode.ToUpper(), defineStr);
propertyGroup.AppendChild(defineConstants);
var allowUnsafeBlocks = doc.CreateElement("AllowUnsafeBlocks");
allowUnsafeBlocks.InnerText = "false";
propertyGroup.AppendChild(allowUnsafeBlocks);
return propertyGroup;
}
private static XmlElement GenReferenceItemGroup(XmlDocument doc)
{
var itemGroup = doc.CreateElement("ItemGroup");
itemGroup.AppendChild(GenerateReference(doc, "mscorlib"));
itemGroup.AppendChild(GenerateReference(doc, "System"));
itemGroup.AppendChild(GenerateReference(doc, "System.XML"));
itemGroup.AppendChild(GenerateReference(doc, "System.Core"));
itemGroup.AppendChild(GenerateReference(doc, "System.Runtime.Serialization"));
itemGroup.AppendChild(GenerateReference(doc, "System.Xml.Linq"));
itemGroup.AppendChild(GenerateReference(doc, "UnityEngine", Path.Combine(UnityEditorPathTool.GetManagedFolder(), @"UnityEngine.dll")));
itemGroup.AppendChild(GenerateReference(doc, "UnityEditor", Path.Combine(UnityEditorPathTool.GetManagedFolder(), @"UnityEditor.dll")));
itemGroup.AppendChild(GenerateReference(doc, "UnityEngine.UI",
Path.Combine(UnityEditorPathTool.GetContentFolder(), @"UnityExtensions\Unity\GUISystem\UnityEngine.UI.dll")));
itemGroup.AppendChild(GenerateReference(doc, "Assembly-CSharp",
string.Format(@"{0}\Library\ScriptAssemblies\Assembly-CSharp.dll",
System.Environment.CurrentDirectory)));
itemGroup.AppendChild(GenerateReference(doc, "Assembly-CSharp-firstpass",
string.Format(@"{0}\Library\ScriptAssemblies\Assembly-CSharp-firstpass.dll",
System.Environment.CurrentDirectory)));
itemGroup.AppendChild(GenerateReference(doc, "DOTween",
string.Format(@"{0}\Assets\ThirdParty\DOTween\DOTween.dll",
System.Environment.CurrentDirectory)));
return itemGroup;
}
private static XmlElement GenerateReference(XmlDocument doc, string library, string hintPath = null)
{
var reference = doc.CreateElement("Reference");
reference.SetAttribute("Include", library);
if (hintPath != null)
{
var hintPathNode = doc.CreateElement("HintPath");
hintPathNode.InnerText = hintPath;
reference.AppendChild(hintPathNode);
}
return reference;
}
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lbzcode/UnityFun.git
git@gitee.com:lbzcode/UnityFun.git
lbzcode
UnityFun
UnityFun
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /