コード例 #1
0
ファイル: GitManager.cs プロジェクト: wuzhangwuzhang/UniGit
        internal static void Initlize()
        {
            repoPathCached = Application.dataPath.Replace("/Assets", "").Replace("/", "\\");
            gitPathCached  = Application.dataPath.Replace("Assets", ".git");

            if (!IsValidRepo)
            {
                return;
            }

            LoadGitSettings();

            GitResourceManager.Initilize();
            GitCredentialsManager.Load();
            GitOverlay.Initlize();
            GitLfsManager.Load();
            GitHookManager.Load();
            GitExternalManager.Load();

            needsFetch                 = !EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isCompiling && !EditorApplication.isUpdating;
            repositoryDirty            = true;
            GitCallbacks.EditorUpdate += OnEditorUpdate;
        }
コード例 #2
0
ファイル: UniGitLoader.cs プロジェクト: oznogongames/UniGit
        static UniGitLoader()
        {
            Profiler.BeginSample("UniGit Initialization");
            try
            {
                injectionHelper = new InjectionHelper();
                GitWindows.Init();
                var recompileChecker = ScriptableObject.CreateInstance <AssemblyReloadScriptableChecker>();
                recompileChecker.OnBeforeReloadAction = OnBeforeAssemblyReload;

                string repoPath     = Application.dataPath.Replace(UniGitPath.UnityDeirectorySeparatorChar + "Assets", "").Replace(UniGitPath.UnityDeirectorySeparatorChar, Path.DirectorySeparatorChar);
                string settingsPath = UniGitPath.Combine(repoPath, ".git", "UniGit", "Settings.json");

                injectionHelper.Bind <string>().FromInstance(repoPath).WithId("repoPath");
                injectionHelper.Bind <string>().FromInstance(settingsPath).WithId("settingsPath");

                injectionHelper.Bind <GitCallbacks>().FromMethod(() =>
                {
                    var c = new GitCallbacks();
                    EditorApplication.update += c.IssueEditorUpdate;
                    c.RefreshAssetDatabase   += AssetDatabase.Refresh;
                    c.SaveAssetDatabase      += AssetDatabase.SaveAssets;
                    EditorApplication.projectWindowItemOnGUI += c.IssueProjectWindowItemOnGUI;
                    //asset postprocessing
                    GitAssetPostprocessors.OnWillSaveAssetsEvent            += c.IssueOnWillSaveAssets;
                    GitAssetPostprocessors.OnPostprocessImportedAssetsEvent += c.IssueOnPostprocessImportedAssets;
                    GitAssetPostprocessors.OnPostprocessDeletedAssetsEvent  += c.IssueOnPostprocessDeletedAssets;
                    GitAssetPostprocessors.OnPostprocessMovedAssetsEvent    += c.IssueOnPostprocessMovedAssets;
                    return(c);
                });
                injectionHelper.Bind <IGitPrefs>().To <UnityEditorGitPrefs>();
                injectionHelper.Bind <GitManager>();
                injectionHelper.Bind <GitSettingsJson>();
                injectionHelper.Bind <GitSettingsManager>();
                injectionHelper.Bind <GitAsyncManager>();

                GitManager = injectionHelper.GetInstance <GitManager>();
                GitManager.Callbacks.RepositoryCreate += OnRepositoryCreate;

                GitUnityMenu.Init(GitManager);
                GitResourceManager.Initilize();
                GitOverlay.Initlize();

                //credentials
                injectionHelper.Bind <ICredentialsAdapter>().To <WincredCredentialsAdapter>();
                injectionHelper.Bind <GitCredentialsManager>();
                //externals
                injectionHelper.Bind <IExternalAdapter>().To <GitExtensionsAdapter>();
                injectionHelper.Bind <IExternalAdapter>().To <TortoiseGitAdapter>();
                injectionHelper.Bind <GitExternalManager>();
                injectionHelper.Bind <GitLfsManager>();
                //hooks
                injectionHelper.Bind <GitPushHookBase>().To <GitLfsPrePushHook>();
                injectionHelper.Bind <GitHookManager>();
                //helpers
                injectionHelper.Bind <GitLfsHelper>();
                injectionHelper.Bind <FileLinesReader>();
                //project window overlays
                injectionHelper.Bind <GitProjectOverlay>();

                if (!Repository.IsValid(repoPath))
                {
                    EditorApplication.delayCall += OnDelayedInit;
                }
                else
                {
                    Rebuild(injectionHelper);
                    EditorApplication.delayCall += OnDelayedInit;
                }
            }
            finally
            {
                Profiler.EndSample();
            }
        }