Unity Git项目添加子模块

在 当前仓库根目录下执行命令

git submodule add https://github.com/xxx/child.git

检查仓库状态

git status

更新子库

git submodule update --remote

下拉父仓库Git并保住子库也更新

git pull --recurse-submodules

推荐使用 Githubdesktop工具

这样你可以更清楚的看到自己子库关联状态

在Unity本使用脚本调用Git

csharp 复制代码
public static void NewGitCommand( string arguments, string WorkingDirectory = "./" )
    {
        string gitPath = "git";
        ProcessStartInfo startInfo = new ProcessStartInfo( gitPath, arguments )
        {
            WindowStyle = ProcessWindowStyle.Hidden,
            UseShellExecute = false,
            ErrorDialog = false,
            CreateNoWindow = true,
            RedirectStandardError = true,
            RedirectStandardInput = true,
            RedirectStandardOutput = true,
            LoadUserProfile = true,
            WorkingDirectory = WorkingDirectory
        };
        var p = new Process { StartInfo = startInfo };
        p.OutputDataReceived += new DataReceivedEventHandler( ( object sender, DataReceivedEventArgs eventArgs ) =>
        {
            if ( !string.IsNullOrEmpty( eventArgs.Data ) )
            {
                Debug.Log(eventArgs.Data);
            }
        } );
        p.ErrorDataReceived += new DataReceivedEventHandler( ( object sender, DataReceivedEventArgs eventArgs ) =>
        {
            if ( !string.IsNullOrEmpty( eventArgs.Data ) )
            {
                Debug.Log( eventArgs.Data );
            }
        } );
        p.Start();
        p.BeginOutputReadLine();
        p.WaitForExit();
        p.Close();
        p.Dispose(); 
    }

案例

csharp 复制代码
   public static void InitOrUpdateSubmodule()
    {
        //Log.PINK( "Begin Update Submodule ======>" );
        NewGitCommand( "submodule update --init --recursive" );
        NewGitCommand( "pull" );
        NewGitCommand( "submodule update" );
        NewGitCommand( "submodule update --remote" );
        AssetDatabase.Refresh();
        //Log.PINK( "End Update Submodule ======>" );
    }
相关推荐
aqiu~6 小时前
VSCode编辑器用于Unity项目
vscode·unity
天若有情6738 小时前
【C++原创开源】formort.h:一行头文件,实现比JS模板字符串更爽的链式拼接+响应式变量
开发语言·javascript·c++·git·github·开源项目·模版字符串
海盗12349 小时前
在群晖NAS上使用Git Server
git
y小花9 小时前
git常用指令
git
华科大胡子9 小时前
开源项目 Git 贡献全流程拆解
git
极地星光9 小时前
工程中:Git 子模块(submodule) vs 直接依赖(源码/库/包管理器)
git
无限进步_10 小时前
【C++&string】大数相乘算法详解:从字符串加法到乘法实现
java·开发语言·c++·git·算法·github·visual studio
无限进步_11 小时前
【C++】验证回文字符串:高效算法详解与优化
java·开发语言·c++·git·算法·github·visual studio
小贺儿开发14 小时前
Unity3D 心理沙盘互动演示
unity·ai·pdf·人机交互·工具·互动·心理沙盘
无限进步_15 小时前
【C++】重载、重写和重定义的区别详解
c语言·开发语言·c++·ide·windows·git·github