Skip to content

Instantly share code, notes, and snippets.

View ababilinski's full-sized avatar
🤠

Adrian Babilinski ababilinski

🤠
View GitHub Profile
@ababilinski
ababilinski / AndroidIntentExtras.cs
Last active June 10, 2025 00:22
Utilities for reading Android Intent extras in Unity and mapping them directly onto C# data classes.
// ────────────────────────────────────────────────────────────────────────────────
// Description: Utilities for reading Android Intent extras in Unity and mapping
// them directly onto C# data classes with strong typing.
// ────────────────────────────────────────────────────────────────────────────────
#nullable enable
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
@ababilinski
ababilinski / GetOrAddComponentExtensions.cs
Created May 27, 2025 20:13
Extension helpers that either return an existing component or add one if it doesn’t exist.
// Extension helpers that either return an existing component
// or add one if it doesn’t exist—zero allocations.
//
// Usage examples:
//
// var rb = gameObject.GetOrAddComponent<Rigidbody>();
// var cam = this.GetOrAddComponentInChildren<Camera>(includeInactive: true);
//
@ababilinski
ababilinski / ComponentExtensions.cs
Created May 27, 2025 19:26
Tiny extension helpers that turn the ubiquitous GetComponent<T>() pattern into a zero-cost cached call. Supports children, parents, scene-wide singletons, and a coroutine to wait for a type to appear.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Events;
using Object = UnityEngine.Object;
// ReSharper disable UnusedParameter.Global
namespace Common.Extensions
{
@ababilinski
ababilinski / WebCameraShader.shader
Created February 12, 2024 16:30
Web Camera Shader With Rotate Property
//Shader to rotate an image from a Unity WebCameraTexture.
Shader "Custom/Web Camera Shader"
{
Properties
{
_MainTex ( "Main Texture", 2D ) = "white" {}
_RotationDegrees ( "Rotation Degrees", Float) = 0
}
@ababilinski
ababilinski / convert-json-to-csv.ipynb
Last active May 13, 2025 16:10
convert-json-to-csv
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ababilinski
ababilinski / PlayParticlesInEditorExtension.cs
Last active October 14, 2024 07:35
Play particles in editor without having the simulation selected.
/* LICENSE
Copyright (c) 2021 Adrian Babilinski
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
@ababilinski
ababilinski / EditorGuiUtility.cs
Created July 24, 2020 17:27
A script for drawing horizontal lines inside of the Unity Editor
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
public static class EditorGuiUtility
{
public static void DrawUILine(Color color, int thickness = 2, int padding = 10)
{
Rect r = EditorGUILayout.GetControlRect(GUILayout.Height(padding+thickness));
@ababilinski
ababilinski / SingletonScriptableObject.cs
Last active March 17, 2021 16:16
Abstract class for making reload-proof singletons out of Uniy3D ScriptableObjects
using System.Linq;
using UnityEngine;
/// <summary>
/// Abstract class for making reload-proof singletons out of ScriptableObjects
/// Returns the asset created on editor, null if there is none
/// Based on https://www.youtube.com/watch?v=VBA1QCoEAX4
/// </summary>
/// <typeparam name="T">Type of the singleton</typeparam>
@ababilinski
ababilinski / ResizeTool.cs
Last active March 17, 2021 15:52
A method that allows for fast GPU resizing in the Unity Engine.
/* LICENSE
Copyright (c) 2019 Adrian Babilinski
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: