예제 #1
0
        public GitProjectOverlay(GitManager gitManager,
                                 GitCallbacks gitCallbacks,
                                 GitSettingsJson gitSettings,
                                 GitAsyncManager asyncManager,
                                 GitReflectionHelper reflectionHelper,
                                 GitOverlay gitOverlay,
                                 IGitPrefs prefs,
                                 UniGitData data,
                                 ILogger logger,
                                 InjectionHelper injectionHelper,
                                 [UniGitInjectOptional] bool cullNonAssetPaths = true)
        {
            if (iconStyle == null)
            {
                iconStyle = new GUIStyle
                {
                    imagePosition = ImagePosition.ImageOnly,
                    alignment     = TextAnchor.LowerLeft,
                    padding       = new RectOffset(2, 2, 2, 2)
                };
                lineStyle = new GUIStyle(EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).FindStyle("IN Title"))
                {
                    padding       = new RectOffset(),
                    margin        = new RectOffset(),
                    contentOffset = Vector2.zero,
                    fixedHeight   = 0,
                    fixedWidth    = 0,
                    border        = { left = 0, right = 0 }
                };
            }

            this.logger            = logger;
            this.data              = data;
            this.gitManager        = gitManager;
            this.gitSettings       = gitSettings;
            this.asyncManager      = asyncManager;
            this.gitCallbacks      = gitCallbacks;
            this.reflectionHelper  = reflectionHelper;
            this.gitOverlay        = gitOverlay;
            this.prefs             = prefs;
            this.cullNonAssetPaths = cullNonAssetPaths;
            this.injectionHelper   = injectionHelper;

            gitManager.AddWatcher(this);

            gitCallbacks.EditorUpdate           += OnEditorUpdate;
            gitCallbacks.ProjectWindowItemOnGUI += CustomIcons;
            gitCallbacks.UpdateRepository       += OnUpdateRepository;

            //project browsers only get created before delay call but not before constructor
            gitCallbacks.DelayCall += () =>
            {
                projectWindows = new List <EditorWindow>(Resources.FindObjectsOfTypeAll(reflectionHelper.ProjectWindowType).Cast <EditorWindow>());
            };

            //shortcut to getting instance id without loading asset
            var method = typeof(AssetDatabase).GetMethod("GetMainAssetOrInProgressProxyInstanceID", BindingFlags.NonPublic | BindingFlags.Static);

            if (method != null)
            {
                GetMainAssetOrInProgressProxyInstanceID = (Func <string, int>)Delegate.CreateDelegate(typeof(Func <string, int>), method);
            }
        }