Skip to content

Instantly share code, notes, and snippets.

@yasirkula
yasirkula / ConvertTexturesToPNG.cs
Last active March 15, 2024 02:51
Convert all TGA, TIFF, PSD and BMP (customizable) Textures to PNG to reduce the project size without any quality loss in Unity
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;
using Debug = UnityEngine.Debug;
using Object = UnityEngine.Object;
@yasirkula
yasirkula / SingleColorTextureDetector.cs
Last active November 15, 2023 20:12
Find Textures with only a single color in a Unity project
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
public class SingleColorTextureDetector : EditorWindow, IHasCustomMenu
{
@yasirkula
yasirkula / UnlitWithShadows.shader
Last active March 3, 2021 05:17
Unlit shader with shadows support for Unity's Built-in Render Pipeline
Shader "Unlit/Texture with Shadows"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Texture", 2D) = "white"
}
SubShader
{
Tags { "RenderType"="Opaque" "Queue"="Geometry" }
@yasirkula
yasirkula / DuplicateAssetDetector.cs
Last active April 25, 2024 23:29
Find duplicate assets in Unity
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Security.Cryptography;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
using Object = UnityEngine.Object;
@yasirkula
yasirkula / ShaderStripper.cs
Last active March 4, 2024 09:40
Stripping commonly unused shader variants in Unity's built-in render pipeline
//#define SHADER_COMPILATION_LOGGING
//#define SKIP_SHADER_COMPILATION
using System.Collections.Generic;
using UnityEditor.Build;
using UnityEditor.Rendering;
using UnityEngine;
using UnityEngine.Rendering;
public class ShaderStripper : IPreprocessShaders
@yasirkula
yasirkula / SerializedPropertyRawValueGetter.cs
Last active April 30, 2021 03:07
Get/set the raw System.Object value of a SerializedProperty in Unity 3D
using System;
using System.Collections;
using System.Reflection;
using UnityEditor;
// Credit: http://answers.unity.com/answers/425602/view.html (I've only slightly modified the code)
public static class SerializedPropertyRawValueGetter
{
public static object GetRawValue( this SerializedProperty property )
{
@yasirkula
yasirkula / MultiScreenshotCapture.cs
Last active April 22, 2024 11:09
Capture multiple screenshots with different resolutions simultaneously in Unity 3D
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace MultiScreenshotCaptureNamespace
{
internal static class ReflectionExtensions
@yasirkula
yasirkula / UnitypackageExtractor.cs
Last active March 12, 2024 00:44
Extract a .unitypackage to any directory (even outside the project folder) from within Unity
#define STOP_EXTRACTION_WHEN_WINDOW_CLOSED
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Text;
using System.Threading;
using UnityEditor;
@yasirkula
yasirkula / SlicedFilledImage.cs
Last active April 20, 2024 12:29
Combining UI Image's Sliced+Filled features together in Unity
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
#if UNITY_2017_4 || UNITY_2018_2_OR_NEWER
using UnityEngine.U2D;
#endif
using Sprites = UnityEngine.Sprites;
#if UNITY_EDITOR
@yasirkula
yasirkula / ScriptedAnimations.cs
Last active March 8, 2024 02:28
GC-free animation system for simple animations like scaling/moving objects or fading a UI element in Unity
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace ScriptedAnim
{
// Hide from Add Component menu
[AddComponentMenu( "" )]
public class ScriptedAnimations : MonoBehaviour
{