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,8 @@
fileFormatVersion: 2
guid: 7f0a7572d89767a40bf04793e3278fc5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -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
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 55758c7903faa9e40b904ac1d00f4020
timeCreated: 1674134791
@@ -0,0 +1,106 @@
using UnityEditor;
using UnityEngine;
namespace IconsCreationTool.Editor.Utility.Helpers
{
internal static class LayersHelper
{
/// <summary>
/// Create a layer at the next available index. Returns silently if layer already exists.
/// </summary>
/// <param name="newLayerName">Name of the layer to create</param>
public static void CreateLayer(string newLayerName)
{
if (string.IsNullOrEmpty(newLayerName))
{
throw new System.ArgumentNullException(nameof(newLayerName),
"New layer name string is either null or empty.");
}
const int builtInLayersCount = 5;
SerializedObject tagManager =
new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
SerializedProperty layersProperty = tagManager.FindProperty("layers");
int layersCount = layersProperty.arraySize;
SerializedProperty firstEmptyLayerProperty = null;
for (int i = 0; i < layersCount; i++)
{
SerializedProperty layerProperty = layersProperty.GetArrayElementAtIndex(i);
string layerName = layerProperty.stringValue;
if (layerName == newLayerName)
{
return;
}
if (i < builtInLayersCount || layerName != string.Empty)
{
continue;
}
firstEmptyLayerProperty ??= layerProperty;
}
if (firstEmptyLayerProperty == null)
{
Debug.LogError("Maximum limit of " + layersCount + " layers exceeded. Layer \"" + newLayerName + "\" not created.");
return;
}
firstEmptyLayerProperty.stringValue = newLayerName;
tagManager.ApplyModifiedProperties();
}
public static void RemoveLayer(string existingLayerName)
{
if (string.IsNullOrEmpty(existingLayerName))
{
throw new System.ArgumentNullException(nameof(existingLayerName),
"Layer name string is either null or empty.");
}
const int builtInLayersCount = 5;
SerializedObject tagManager =
new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
SerializedProperty layersProperty = tagManager.FindProperty("layers");
int layersCount = layersProperty.arraySize;
SerializedProperty existingLayerProperty = null;
for (int i = 0; i < layersCount; i++)
{
SerializedProperty layerProperty = layersProperty.GetArrayElementAtIndex(i);
string layerName = layerProperty.stringValue;
bool validLayer = i < builtInLayersCount || layerName != string.Empty;
if (!validLayer)
{
continue;
}
if (layerName != existingLayerName)
{
continue;
}
existingLayerProperty ??= layerProperty;
}
if (existingLayerProperty == null)
{
Debug.LogError($"Layer named \"{existingLayerName}\" was not found!");
return;
}
existingLayerProperty.stringValue = string.Empty;
tagManager.ApplyModifiedProperties();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 836ab8032815695489738920b838a6da
timeCreated: 1674134797