Skip to content

Instantly share code, notes, and snippets.

Avatar
🐤

Süleyman Yasir KULA yasirkula

🐤
View GitHub Profile
@yasirkula
yasirkula / PaddingIgnoringImage.cs
Last active Apr 3, 2022
Modified version of Image component that ignores the sprite's padding in Unity
View PaddingIgnoringImage.cs
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Sprites;
using UnityEngine.UI;
#if UNITY_2017_4 || UNITY_2018_2_OR_NEWER
using UnityEngine.U2D;
#endif
#if UNITY_EDITOR
using UnityEditor;
@yasirkula
yasirkula / CustomMaxSizeSetter.cs
Created Mar 13, 2022
Set non-power-of-2 Max Size values for textures/sprites in Unity
View CustomMaxSizeSetter.cs
using UnityEditor;
using UnityEngine;
public class CustomMaxSizeSetter : EditorWindow
{
private const int MINIMUM_MAX_SIZE = 32;
private const int MAXIMUM_MAX_SIZE = 2048;
private int initialMaxSize = -1;
private int currentMaxSize = -1;
@yasirkula
yasirkula / WavyImage.cs
Created Nov 20, 2021
Create UI image with wave animation in Unity
View WavyImage.cs
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Sprites;
using UnityEngine.UI;
#if UNITY_2017_4 || UNITY_2018_2_OR_NEWER
using UnityEngine.U2D;
#endif
#if UNITY_EDITOR
using UnityEditor;
@yasirkula
yasirkula / IAPManager.cs
Created Nov 4, 2021
A wrapper script for Unity IAP (In-App Purchases) that can be used for common IAP tasks
View IAPManager.cs
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Purchasing;
using UnityEngine.Purchasing.Security;
public class IAPManager : IStoreListener
{
public enum State { PendingInitialize, Initializing, SuccessfullyInitialized, FailedToInitialize };
@yasirkula
yasirkula / ScrollViewFocusFunctions.cs
Created Oct 23, 2021
Focus/center Scroll View to the specified point/item in Unity
View ScrollViewFocusFunctions.cs
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public static class ScrollViewFocusFunctions
{
public static Vector2 CalculateFocusedScrollPosition( this ScrollRect scrollView, Vector2 focusPoint )
{
Vector2 contentSize = scrollView.content.rect.size;
Vector2 viewportSize = ( (RectTransform) scrollView.content.parent ).rect.size;
@yasirkula
yasirkula / CustomRectHandles.cs
Created Aug 7, 2021
Drawing Rect handles in Unity (similar to built-in Rect tool)
View CustomRectHandles.cs
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;
public class CustomRectHandles : ScriptableObject
{
public class Rect3D
{
@yasirkula
yasirkula / BoxColliderWizard.cs
Last active Nov 18, 2022
Creating & editing BoxColliders intuitively in Unity
View BoxColliderWizard.cs
#if UNITY_EDITOR
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEngine.Rendering;
#endif
using UnityEngine;
public class BoxColliderWizard : MonoBehaviour
@yasirkula
yasirkula / BatchExtractMaterials.cs
Last active Nov 13, 2022
Batch extract materials from 3D model assets in Unity
View BatchExtractMaterials.cs
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using System.IO;
public class BatchExtractMaterials : EditorWindow
{
private enum ExtractMode { Extract = 0, Remap = 1, Ignore = 2 };
[System.Serializable]
@yasirkula
yasirkula / ConvertTexturesToPNG.cs
Last active Nov 29, 2022
Convert all TGA, TIFF, PSD and BMP (customizable) Textures to PNG to reduce the project size without any quality loss in Unity
View ConvertTexturesToPNG.cs
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 Dec 11, 2021
Find Textures with only a single color in a Unity project
View SingleColorTextureDetector.cs
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
{