-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from badawe/feature/tweaks_and_optimizations
Feature/tweaks and optimizations
- Loading branch information
Showing
22 changed files
with
788 additions
and
150 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
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,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using UnityEditor; | ||
|
||
namespace UnityEngine | ||
{ | ||
public static partial class DefaultAssetExtensions | ||
{ | ||
public static List<T> GetChildrenObjectsOfType<T>(this DefaultAsset targetDefaultAsset) where T : Object | ||
{ | ||
string targetFolder = AssetDatabase.GetAssetPath(targetDefaultAsset); | ||
List<T> result = new List<T>(); | ||
|
||
string[] guids = AssetDatabase.FindAssets($"t:{typeof(T).Name}", new[] {targetFolder}); | ||
Uri rootFolder = new Uri(Path.GetFullPath(targetFolder)); | ||
for (int i = 0; i < guids.Length; i++) | ||
{ | ||
string objectPath = AssetDatabase.GUIDToAssetPath(guids[i]); | ||
Uri spriteUri = new Uri(Path.GetFullPath(objectPath)); | ||
|
||
if (rootFolder != spriteUri && rootFolder.IsBaseOf(spriteUri)) | ||
{ | ||
IEnumerable<T> foundObjects = AssetDatabase.LoadAllAssetsAtPath(objectPath).Where(o => o is T) | ||
.Cast<T>(); | ||
result.AddRange(foundObjects); | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
} | ||
} |
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
File renamed without changes.
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,17 @@ | ||
using System.Linq; | ||
using UnityEditor; | ||
|
||
namespace UnityEngine | ||
{ | ||
public static partial class Texture2DExtensions | ||
{ | ||
public static bool TryLoadSprites(this Texture2D texture, out Sprite[] sprites ) | ||
{ | ||
string texturePath = AssetDatabase.GetAssetPath(texture); | ||
sprites = AssetDatabase.LoadAllAssetsAtPath(texturePath) | ||
.Where(o => o is Sprite).Cast<Sprite>().ToArray(); | ||
|
||
return sprites.Length > 0; | ||
} | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.