Skip to content

Instantly share code, notes, and snippets.

Avatar
🐤

Süleyman Yasir KULA yasirkula

🐤
View GitHub Profile
@yasirkula
yasirkula / ShaderStripper.cs
Last active Nov 24, 2020
Stripping commonly unused shader variants in Unity's built-in render pipeline
View ShaderStripper.cs
//#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 Aug 8, 2020
Get/set the raw System.Object value of a SerializedProperty in Unity 3D
View SerializedPropertyRawValueGetter.cs
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 Oct 1, 2020
Capture multiple screenshots with different resolutions simultaneously in Unity 3D
View MultiScreenshotCapture.cs
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 Oct 30, 2020
Extract a .unitypackage to any directory (even outside the project folder) from within Unity
View UnitypackageExtractor.cs
//#define OPEN_ASSET_STORE_CACHE_AS_INITIAL_PATH
#define STOP_EXTRACTION_WHEN_WINDOW_CLOSED
using System;
using System.IO;
using System.IO.Compression;
using System.Text;
using System.Threading;
using UnityEditor;
using UnityEngine;
@yasirkula
yasirkula / SlicedFilledImage.cs
Last active Nov 25, 2020
Combining UI Image's Sliced+Filled features together in Unity
View SlicedFilledImage.cs
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 Nov 3, 2020
GC-free animation system for simple animations like scaling/moving objects or fading a UI element in Unity
View ScriptedAnimations.cs
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace ScriptedAnim
{
// Hide from Add Component menu
[AddComponentMenu( "" )]
public class ScriptedAnimations : MonoBehaviour
{
@yasirkula
yasirkula / DirectoryComparer.cs
Last active Mar 17, 2020
Compare the contents of two directories and apply any changes to the target directory to synchronize these two directories
View DirectoryComparer.cs
#define COMPARE_FILE_CONTENTS
#if COMPARE_FILE_CONTENTS
#define USE_THREADS
#endif
using System;
using System.Collections.Generic;
using System.IO;
#if USE_THREADS
using System.Threading;
@yasirkula
yasirkula / UIToggler.cs
Last active Jan 11, 2020
Quickly toggle the visibility of UI layer (canvases) in Unity's Scene view
View UIToggler.cs
using UnityEditor;
using UnityEngine;
public class UIToggler
{
private const int UI_LAYER = 1 << 5;
[InitializeOnLoadMethod]
private static void Init()
{
@yasirkula
yasirkula / EmptyParentCreator.cs
Last active Oct 21, 2019
Group the selected objects under a new parent object in Hierarchy (Unity 3D)
View EmptyParentCreator.cs
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public static class EmptyParentCreator
{
[MenuItem( "GameObject/Create Empty Parent", priority = 0 )]
private static void CreateEmptyParent( MenuCommand command )
{
// This happens when this button is clicked via hierarchy's right click context menu
@yasirkula
yasirkula / BetterWaitForSeconds.cs
Created Oct 13, 2019
WaitForSeconds manager that reuses instances to avoid GC in Unity
View BetterWaitForSeconds.cs
using System.Collections.Generic;
using UnityEngine;
public static class BetterWaitForSeconds
{
private class WaitForSeconds : CustomYieldInstruction
{
private float waitUntil;
public override bool keepWaiting
{
You can’t perform that action at this time.