Skip to content

Commit

Permalink
Merged branch develop into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Borod4r committed Feb 26, 2017
2 parents ce07fe2 + 9ee6534 commit cdeab82
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class AssetInfo
{
public const string STORE_ID = "50668";
public const string NAME = "Rainbow Folders";
public const string VERSION = "0.7";
public const string VERSION = "0.7.1";
public const string HELP_URL = "http://www.borodar.com/stuff/rainbowfolders/docs/quickstart_v" + VERSION + ".pdf";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System.Reflection;
using Borodar.RainbowFolders.Editor.Settings;
using UnityEditor;
using UnityEditor.VersionControl;
using UnityEngine;
using ProjectWindowItemCallback = UnityEditor.EditorApplication.ProjectWindowItemCallback;

Expand All @@ -34,7 +35,9 @@ public class RainbowFoldersBrowserIcons
private const float LARGE_ICON_SIZE = 64f;

private static Func<bool> _isCollabEnabled;
private static Func<bool> _isVcsEnabled;
private static ProjectWindowItemCallback _drawCollabOverlay;
private static ProjectWindowItemCallback _drawVcsOverlay;
private static bool _multiSelection;

//---------------------------------------------------------------------
Expand All @@ -46,7 +49,10 @@ static RainbowFoldersBrowserIcons()
EditorApplication.projectWindowItemOnGUI += ReplaceFolderIcon;
EditorApplication.projectWindowItemOnGUI += DrawEditIcon;
EditorApplication.projectWindowItemOnGUI += ShowWelcomeWindow;
InitCollabDelegates();

var assembly = typeof(EditorApplication).Assembly;
InitCollabDelegates(assembly);
InitVcsDelegates(assembly);
}

//---------------------------------------------------------------------
Expand All @@ -65,7 +71,7 @@ private static void ReplaceFolderIcon(string guid, Rect rect)
var texture = RainbowFoldersSettings.Instance.GetFolderIcon(path, isSmall);
if (texture == null) return;

DrawCustomIcon(guid, ref rect, texture, isSmall);
DrawCustomIcon(guid, rect, texture, isSmall);
}

private static void DrawEditIcon(string guid, Rect rect)
Expand All @@ -87,7 +93,7 @@ private static void DrawEditIcon(string guid, Rect rect)
if (!AssetDatabase.IsValidFolder(path)) return;

var editIcon = RainbowFoldersEditorUtility.GetEditFolderIcon(isSmall);
DrawCustomIcon(guid, ref rect, editIcon, isSmall);
DrawCustomIcon(guid, rect, editIcon, isSmall);

if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
{
Expand Down Expand Up @@ -115,10 +121,29 @@ private static void ShowWelcomeWindow(string guid, Rect rect)
// Helpers
//---------------------------------------------------------------------

private static void InitCollabDelegates()
private static void InitVcsDelegates(Assembly assembly)
{
var assembly = typeof(EditorApplication).Assembly;
try
{
_isVcsEnabled = () => Provider.isActive;

var vcsHookType = assembly.GetType("UnityEditorInternal.VersionControl.ProjectHooks");
var vcsHook = vcsHookType.GetMethod("OnProjectWindowItem", BindingFlags.Static | BindingFlags.Public);
_drawVcsOverlay = (ProjectWindowItemCallback) Delegate.CreateDelegate(typeof(ProjectWindowItemCallback), vcsHook);
}
catch (SystemException ex)
{
if (!(ex is NullReferenceException) && !(ex is ArgumentNullException)) throw;
_isVcsEnabled = () => false;

#if RAINBOW_FOLDERS_DEVEL
Debug.LogException(ex);
#endif
}
}

private static void InitCollabDelegates(Assembly assembly)
{
try
{
var collabAccessType = assembly.GetType("UnityEditor.Web.CollabAccess");
Expand Down Expand Up @@ -162,35 +187,38 @@ private static void ShowPopupWindow(Rect rect, string path)
}
}

private static void DrawCustomIcon(string guid, ref Rect rect, Texture texture, bool isSmall)
private static void DrawCustomIcon(string guid, Rect rect, Texture texture, bool isSmall)
{
var iconRect = rect;
if (rect.width > LARGE_ICON_SIZE)
{
// center the icon if it is zoomed
var offset = (rect.width - LARGE_ICON_SIZE) / 2f;
iconRect = new Rect(rect.x + offset, rect.y + offset, LARGE_ICON_SIZE, LARGE_ICON_SIZE);
rect = new Rect(rect.x + offset, rect.y + offset, LARGE_ICON_SIZE, LARGE_ICON_SIZE);
}
else
{
// unity shifted small icons a bit in 5.4 and 5.5
#if UNITY_5_4_4
if (isSmall) iconRect = new Rect(rect.x + 7, rect.y, rect.width, rect.height);
#elif UNITY_5_5
if (isSmall) iconRect = new Rect(rect.x + 3, rect.y, rect.width, rect.height);
// unity shifted small icons a bit in 5.5
#if UNITY_5_5
if (isSmall) rect = new Rect(rect.x + 3, rect.y, rect.width, rect.height);
#endif
}

if (_isCollabEnabled())
{
var background = RainbowFoldersEditorUtility.GetCollabBackground(isSmall, EditorGUIUtility.isProSkin);
GUI.DrawTexture(iconRect, background);
GUI.DrawTexture(rect, background);
GUI.DrawTexture(rect, texture);
_drawCollabOverlay(guid, rect);
}
else if (_isVcsEnabled())
{
var iconRect = (!isSmall) ? rect : new Rect(rect.x + 7, rect.y, rect.width, rect.height);
GUI.DrawTexture(iconRect, texture);
_drawCollabOverlay(guid, iconRect);
_drawVcsOverlay(guid, rect);
}
else
{
GUI.DrawTexture(iconRect, texture);
GUI.DrawTexture(rect, texture);
}
}

Expand Down
Binary file modified Assets/Plugins/RainbowFolders/QuickStart.pdf
Binary file not shown.

0 comments on commit cdeab82

Please sign in to comment.