示例#1
0
        internal static void Initlize()
        {
            EditorApplication.projectWindowItemOnGUI += CustomIcons;

            if (IconStyle == null)
            {
                IconStyle = new GUIStyle
                {
                    imagePosition = ImagePosition.ImageOnly,
                    alignment     = TextAnchor.LowerLeft,
                    padding       = new RectOffset(2, 2, 2, 2)
                };
            }

            if (icons == null)
            {
                icons = new Icons()
                {
                    validIcon          = new GUIContent(GitResourceManager.GetTexture("success")),
                    validIconSmall     = new GUIContent(GitResourceManager.GetTexture("success_small")),
                    modifiedIcon       = new GUIContent(GitResourceManager.GetTexture("error")),
                    modifiedIconSmall  = new GUIContent(GitResourceManager.GetTexture("error_small")),
                    addedIcon          = new GUIContent(GitResourceManager.GetTexture("add")),
                    addedIconSmall     = new GUIContent(GitResourceManager.GetTexture("add_small")),
                    untrackedIcon      = new GUIContent(GitResourceManager.GetTexture("info")),
                    untrackedIconSmall = new GUIContent(GitResourceManager.GetTexture("info_small")),
                    ignoredIcon        = new GUIContent(GitResourceManager.GetTexture("minus")),
                    ignoredIconSmall   = new GUIContent(GitResourceManager.GetTexture("minus_small")),
                    conflictIcon       = new GUIContent(GitResourceManager.GetTexture("warning")),
                    conflictIconSmall  = new GUIContent(GitResourceManager.GetTexture("warning_small")),
                    deletedIcon        = new GUIContent(GitResourceManager.GetTexture("deleted")),
                    deletedIconSmall   = new GUIContent(GitResourceManager.GetTexture("deleted_small")),
                    renamedIcon        = new GUIContent(GitResourceManager.GetTexture("renamed")),
                    renamedIconSmall   = new GUIContent(GitResourceManager.GetTexture("renamed_small")),
                    loadingIconSmall   = new GUIContent(GitResourceManager.GetTexture("loading")),
                    objectIcon         = new GUIContent(GitResourceManager.GetTexture("object")),
                    objectIconSmall    = new GUIContent(GitResourceManager.GetTexture("object_small")),
                    metaIcon           = new GUIContent(GitResourceManager.GetTexture("meta")),
                    metaIconSmall      = new GUIContent(GitResourceManager.GetTexture("meta_small")),
                    fetch         = new GUIContent(GitResourceManager.GetTexture("GitFetch")),
                    merge         = new GUIContent(GitResourceManager.GetTexture("GitMerge")),
                    checkout      = new GUIContent(GitResourceManager.GetTexture("GitCheckout")),
                    loadingCircle = new GUIContent(GitResourceManager.GetTexture("loading_circle")),
                    stashIcon     = new GUIContent(GitResourceManager.GetTexture("stash")),
                    unstashIcon   = new GUIContent(GitResourceManager.GetTexture("unstash")),
                };
            }
        }
示例#2
0
 internal static void Initlize()
 {
     if (icons == null)
     {
         icons = new Icons()
         {
             validIcon          = new GUIContent(GitResourceManager.GetTexture("success")),
             validIconSmall     = new GUIContent(GitResourceManager.GetTexture("success_small")),
             modifiedIcon       = new GUIContent(GitResourceManager.GetTexture("error")),
             modifiedIconSmall  = new GUIContent(GitResourceManager.GetTexture("error_small")),
             addedIcon          = new GUIContent(GitResourceManager.GetTexture("add")),
             addedIconSmall     = new GUIContent(GitResourceManager.GetTexture("add_small")),
             untrackedIcon      = new GUIContent(GitResourceManager.GetTexture("info")),
             untrackedIconSmall = new GUIContent(GitResourceManager.GetTexture("info_small")),
             ignoredIcon        = new GUIContent(GitResourceManager.GetTexture("minus")),
             ignoredIconSmall   = new GUIContent(GitResourceManager.GetTexture("minus_small")),
             conflictIcon       = new GUIContent(GitResourceManager.GetTexture("warning")),
             conflictIconSmall  = new GUIContent(GitResourceManager.GetTexture("warning_small")),
             deletedIcon        = new GUIContent(GitResourceManager.GetTexture("deleted")),
             deletedIconSmall   = new GUIContent(GitResourceManager.GetTexture("deleted_small")),
             renamedIcon        = new GUIContent(GitResourceManager.GetTexture("renamed")),
             renamedIconSmall   = new GUIContent(GitResourceManager.GetTexture("renamed_small")),
             loadingIconSmall   = new GUIContent(GitResourceManager.GetTexture("loading")),
             objectIcon         = new GUIContent(GitResourceManager.GetTexture("object")),
             objectIconSmall    = new GUIContent(GitResourceManager.GetTexture("object_small")),
             metaIcon           = new GUIContent(GitResourceManager.GetTexture("meta")),
             metaIconSmall      = new GUIContent(GitResourceManager.GetTexture("meta_small")),
             fetch              = new GUIContent(GitResourceManager.GetTexture("GitFetch")),
             merge              = new GUIContent(GitResourceManager.GetTexture("GitMerge")),
             checkout           = new GUIContent(GitResourceManager.GetTexture("GitCheckout")),
             loadingCircle      = new GUIContent(GitResourceManager.GetTexture("loading_circle")),
             stashIcon          = new GUIContent(GitResourceManager.GetTexture("stash")),
             unstashIcon        = new GUIContent(GitResourceManager.GetTexture("unstash")),
             lfsObjectIcon      = new GUIContent(GitResourceManager.GetTexture("lfs_object")),
             lfsObjectIconSmall = new GUIContent(GitResourceManager.GetTexture("lfs_object_small")),
             donateSmall        = new GUIContent(GitResourceManager.GetTexture("donate"), "Donate"),
             starSmall          = new GUIContent(GitResourceManager.GetTexture("star")),
         };
     }
 }
示例#3
0
        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;
        }
示例#4
0
        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();
            }
        }