-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UnityAssetUtility and UnityRectUtility
- Loading branch information
Showing
4 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#if UNITY_EDITOR | ||
using System; | ||
using UnityEditor; | ||
using Object = UnityEngine.Object; | ||
|
||
namespace Exanite.Core.Utilities | ||
{ | ||
public static class UnityAssetUtility | ||
{ | ||
/// <summary> | ||
/// Returns the override importer of an asset. Returns null when the provided | ||
/// <see cref="Object"/> is not an asset or does not have an override importer. | ||
/// </summary> | ||
/// <remarks> | ||
/// This is a wrapper around <see cref="AssetDatabase.GetImporterOverride"/> to make it easier to use. | ||
/// </remarks> | ||
public static Type GetOverrideImporter(this Object asset) | ||
{ | ||
var path = AssetDatabase.GetAssetPath(asset); | ||
if (string.IsNullOrEmpty(path)) | ||
{ | ||
return null; | ||
} | ||
|
||
return AssetDatabase.GetImporterOverride(path); | ||
} | ||
} | ||
} | ||
#endif |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#if UNITY_2021_3_OR_NEWER | ||
using UnityEngine; | ||
|
||
namespace Exanite.Core.Utilities | ||
{ | ||
public static class UnityRectUtility | ||
{ | ||
public static Rect WithInset(this Rect rect, float inset) | ||
{ | ||
rect.xMin += inset; | ||
rect.yMin += inset; | ||
|
||
rect.xMax -= inset; | ||
rect.yMax -= inset; | ||
|
||
return rect; | ||
} | ||
} | ||
} | ||
#endif |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.