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 ======>" );
    }
相关推荐
jiayong237 分钟前
虚幻引擎 Unreal Engine 通俗指南
游戏引擎·虚幻
郝学胜-神的一滴2 小时前
中级OpenGL教程 008:精准控制高光光斑大小与强度
c++·unity·godot·three.js·图形学·opengl·unreal
屋外雨大,惊蛰出没2 小时前
Git基本应用
git
_Evan_Yao2 小时前
一文搞懂:Git分支管理与团队协作规范——从GitFlow到GitHub Flow,从rebase到merge,打造高效协作流
java·git·后端·github
憧憬成为java架构高手的小白3 小时前
git工作流程简化版
java·spring boot·git
avi91114 小时前
Unity 商业插件之(五)课外2 - Zenject的一些小Tips(学习备忘)
unity·游戏开发·团结引擎
东风微鸣4 小时前
Argo CD 用户管理:本地用户配置与权限分离实践
git·后端
元气少女小圆丶5 小时前
SenseGlove Nova 2+Unity开发笔记4
笔记·unity·游戏引擎
basketball6165 小时前
Go 语言从入门到进阶:6. 一文彻底吃透结构体(Struct)
开发语言·unity·golang
袋子(PJ)6 小时前
2026最新GitHub发布项目全过程
git·github