Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
@unitycoder
unitycoder / readme.md
Created November 21, 2024 15:02 — forked from BarelyAliveMau5/readme.md
How to attach unity profiler to existing WebGL builds on Windows 11

Attaching the Unity profiler to WebGL builds on Windows 11

One of the biggest pains in Unity when developing for WebGL is that if you want to profile it, you have to use the "Build and Run" menu option to do it, while it works, it can be very inconvenient and waste a lot of time recompiling everything, in this brief tutorial I present a way of attaching the profiler without having to recompile everything.

Click here to see the TL;DR (Too long; Didn't Read™) step-by-step if you are not patient enough to read everything

Note: This entire procedure was only tested with Unity 2021.3.29f1. The procedure might be the same in newer versions, but in case it's not, refer below for how I discovered it for this version.

As of 2023-09-28, the Unity documentation states:

@unitycoder
unitycoder / ListMicDevices.cs
Created November 21, 2024 08:09
c# console app, list Microphone Devices
using System;
using System.Runtime.InteropServices;
class Program
{
[DllImport("winmm.dll", SetLastError = true)]
private static extern uint waveInGetNumDevs();
[DllImport("winmm.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern uint waveInGetDevCaps(uint deviceId, ref WAVEINCAPS waveInCaps, uint size);
@unitycoder
unitycoder / DontHitAlpha.cs
Last active November 18, 2024 18:17
Unity dont hit image transparent areas using alphaHitTestMinimumThreshold
// https://docs.unity3d.com/2018.3/Documentation/ScriptReference/UI.Image-alphaHitTestMinimumThreshold.html
// attach this script to UI Image gameobject
// note the image/script needs to have [x] read write enabled in import settings
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class DontHitAlpha : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler
{
@unitycoder
unitycoder / Pool.cs
Created November 12, 2024 12:37
simple object pooling class
// source https://github.com/AlCh3mi/GameJamToolKit/blob/main/GameJamToolkit/ObjectPooling/Pool.cs
using System;
using UnityEngine;
using UnityEngine.Pool;
namespace UnityLibrary.ObjectPooling
{
public abstract class Pool<T> : MonoBehaviour where T : MonoBehaviour
{
@unitycoder
unitycoder / unity-releases.md
Last active December 6, 2024 19:56
Unity Releases Watcher Bot for 6000.1.x (Updates few times per day)
@unitycoder
unitycoder / enemy.cs
Created November 10, 2024 15:08
Projectile motion Unity 3D to always make a Hit to moving object
// https://web.archive.org/web/20150428033712/http://lexiconhub.tk/index/game-programming/projectile-motion-unity-3d/
using UnityEngine;
using System.Collections;
public class enemy : MonoBehaviour
{
public float MinSpeed;
public float MaxSpeed;
public float currentSpeed;
private float x, y, z;
@unitycoder
unitycoder / hls.sh
Created November 8, 2024 21:59 — forked from stenuto/hls.sh
HLS ffmpeg script
#!/bin/bash
# Function to display usage information
usage() {
echo "Usage: $0 /path/to/input.mp4 [ /path/to/output_directory ]"
exit 1
}
# Check if at least one argument (input file) is provided
if [ $# -lt 1 ]; then
@unitycoder
unitycoder / CursorLock.cs
Created November 8, 2024 12:24 — forked from Thaina/CursorLock.cs
Actual pointer lock value in unity webgl and windows editor
using System.Collections;
using System.Collections.Generic;
#if UNITY_EDITOR_WIN || UNITY_WEBGL
using System.Runtime.InteropServices;
#endif
using UnityEngine;
public static class CursorLock
@unitycoder
unitycoder / DebugUtilities.cs
Created November 8, 2024 11:14
Debug draw sphere box script
// https://discussions.unity.com/t/debug-draw-sphere-script/1550055
using System.Collections;
using UnityEngine;
public static class DebugUtilities
{
/// <summary>
/// Draw primitive forms like capsule, cubes ecc... for a N time in a location.
/// (similar to Debug.DrawRay)
/// </summary>