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 ======>" );
    }
相关推荐
Cx330_FCQ3 小时前
Tmux使用
服务器·git·算法
xxwl58510 小时前
Git 完整学习笔记:从入门到团队协作
笔记·git·学习
懒狗跑ai的程序员Brain13 小时前
如何利用粒子系统在unity制作一个烟花(粒子系统学习向)
学习·unity·游戏引擎
John_ToDebug13 小时前
Git 工作区、暂存区、仓库、远端同步完全指南:从 restore、reset 到 fetch、pull 的正确使用姿势
git·源代码管理
xcLeigh14 小时前
Unity基础:材质与纹理入门——给物体穿上“衣服“
unity·游戏引擎·材质
unityのkiven14 小时前
理解 GUILayout 与 EditorGUILayout,并探究 ScrollView 滚轮失效可能的原因
unity
ellis197015 小时前
u3d插件xLua[二]例2:U3DScripting,例3:UIEvent分析
unity·lua
派葛穆1 天前
Unity-UI 输入框功能
ui·unity·游戏引擎
玖玥拾1 天前
Unity3D RPG 入门项目(一)开场动画/人物移动/摄像机跟随场景切换
unity·游戏引擎
炸膛坦客1 天前
Git 和 GitHub:(九)修改本地仓库内容并推送到远程仓库(关联/克隆)
git·github