Initial commit

This commit is contained in:
HussienX72u
2026-07-21 08:56:10 +03:00
commit 4017028111
9410 changed files with 2150500 additions and 0 deletions
@@ -0,0 +1,77 @@
using UnityEngine;
namespace IconsCreationTool.Editor.Utility.Extensions
{
public static class GameObjectExtensions
{
public static Bounds GetOrthographicBounds(this GameObject gameObject, Camera camera)
{
Vector3 minScreenPosition = Vector3.positiveInfinity;
Vector3 maxScreenPosition = Vector3.negativeInfinity;
MeshFilter[] meshFilters = gameObject.GetComponentsInChildren<MeshFilter>();
foreach (MeshFilter meshFilter in meshFilters)
{
if (!meshFilter.sharedMesh)
{
continue;
}
Vector3[] vertices = meshFilter.sharedMesh.vertices;
foreach (Vector3 vertex in vertices)
{
Vector3 wsVertexPosition = meshFilter.transform.TransformPoint(vertex);
Vector3 screenPosition = camera.WorldToScreenPoint(wsVertexPosition);
for (int i = 0; i < 3; i++)
{
minScreenPosition[i] = Mathf.Min(minScreenPosition[i], screenPosition[i]);
maxScreenPosition[i] = Mathf.Max(maxScreenPosition[i], screenPosition[i]);
}
}
}
Vector3 min = camera.ScreenToWorldPoint(minScreenPosition);
Vector3 max = camera.ScreenToWorldPoint(maxScreenPosition);
Bounds bounds = new Bounds();
bounds.SetMinMax(min, max);
return bounds;
}
public static bool HasVisibleMesh(this GameObject gameObject)
{
bool hasVisibleMesh = false;
MeshFilter[] meshFilters = gameObject.GetComponentsInChildren<MeshFilter>();
foreach (MeshFilter meshFilter in meshFilters)
{
if (!meshFilter)
{
continue;
}
bool hasMesh = meshFilter.sharedMesh;
if (!hasMesh)
{
continue;
}
bool hasRendererForMesh = meshFilter.GetComponent<MeshRenderer>();
if (!hasRendererForMesh)
{
continue;
}
hasVisibleMesh = true;
break;
}
return hasVisibleMesh;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8a93b83f00a629740be4e5a9ed5b25e2
timeCreated: 1672935331
@@ -0,0 +1,27 @@
using UnityEngine;
namespace IconsCreationTool.Editor.Utility.Extensions
{
public static class TextureExtensions
{
public static Texture2D Resize(this Texture2D texture, int targetSize)
{
FilterMode filterMode = texture.filterMode;
RenderTexture temporaryRenderTexture = RenderTexture.GetTemporary(targetSize, targetSize);
RenderTexture.active = temporaryRenderTexture;
Graphics.Blit(texture, temporaryRenderTexture);
Texture2D resizedTexture = new Texture2D(targetSize, targetSize);
resizedTexture.filterMode = filterMode;
resizedTexture.ReadPixels(new Rect(0, 0, targetSize, targetSize), 0, 0);
resizedTexture.Apply();
RenderTexture.ReleaseTemporary(temporaryRenderTexture);
return resizedTexture;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d26dc795b5b53ed4ebb17b83dd396c37
timeCreated: 1674288791
@@ -0,0 +1,78 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace IconsCreationTool.Editor.Utility.Extensions
{
public static class UnityObjectExtensions
{
public static List<GameObject> ExtractAllGameObjects(this List<Object> objects)
{
List<GameObject> result = new List<GameObject>();
GameObject[] gameObjects = objects.OfType<GameObject>().ToArray();
result.AddRange(gameObjects);
Object[] folders = objects.Except(gameObjects).Where(o => o.IsFolder()).ToArray();
foreach (Object folder in folders)
{
if (!folder)
{
continue;
}
string folderPath = AssetDatabase.GetAssetPath(folder)[7..];
string[] filesPaths = Directory.GetFiles(Application.dataPath + "/" + folderPath, "*",
SearchOption.AllDirectories);
foreach (string filePath in filesPaths)
{
string relativeFilePath = filePath.Remove(0, Application.dataPath.Length - 6);
GameObject gameObject = AssetDatabase.LoadAssetAtPath<GameObject>(relativeFilePath);
if (gameObject)
{
result.Add(gameObject);
}
}
}
return result;
}
private static bool IsFolder(this Object obj)
{
return AssetDatabase.IsValidFolder(AssetDatabase.GetAssetPath(obj));
}
public static bool IsFolderContainingGameObjects(this Object obj)
{
bool isFolder = obj.IsFolder();
if (!isFolder)
{
return false;
}
bool containsGameObjects = false;
string folderPath = AssetDatabase.GetAssetPath(obj)[7..];
string[] filesPaths = Directory.GetFiles(Application.dataPath + "/" + folderPath, "*",
SearchOption.AllDirectories);
foreach (string filePath in filesPaths)
{
string relativeFilePath = filePath.Remove(0, Application.dataPath.Length - 6);
GameObject gameObject = AssetDatabase.LoadAssetAtPath<GameObject>(relativeFilePath);
if (!gameObject)
{
continue;
}
containsGameObjects = true;
break;
}
return containsGameObjects;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2e4ad67c4f556c54abd1c507d3735328
timeCreated: 1674320433
@@ -0,0 +1,19 @@
using UnityEngine;
namespace IconsCreationTool.Editor.Utility.Extensions
{
public static class VectorExtensions
{
public static Vector2 Abs(this Vector2 a)
{
a.Set(Mathf.Abs(a.x), Mathf.Abs(a.y));
return a;
}
public static float BiggestComponentValue(this Vector2 a)
{
return Mathf.Max(a.x, a.y);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: dab722235641d7f4c9e5bbf9514c2cdc
timeCreated: 1672935401