Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
@unitycoder
unitycoder / Shadows.cginc
Created January 1, 2025 21:33 — forked from runevision/Shadows.cginc
Water Foam Particle Shader
UNITY_DECLARE_SHADOWMAP(_SunCascadedShadowMap);
float4 _SunCascadedShadowMap_TexelSize;
#define GET_CASCADE_WEIGHTS(wpos, z) getCascadeWeights_splitSpheres(wpos)
#define GET_SHADOW_FADE(wpos, z) getShadowFade_SplitSpheres(wpos)
#define GET_SHADOW_COORDINATES(wpos,cascadeWeights) getShadowCoord(wpos,cascadeWeights)
/**
* Gets the cascade weights based on the world position of the fragment and the poisitions of the split spheres for each cascade.
@unitycoder
unitycoder / ProjectionViewer.cs
Created January 1, 2025 21:33 — forked from runevision/ProjectionViewer.cs
Script to create visual illusion of rotating wireframe object that tricks the eye into switching orientation and rotation direction
using UnityEngine;
// Visual effect/illusion where a rotating model alternates between
// seeming to rotate one way around and the other.
// Unlike many similar effects, the eyes are nudged/forced to see it
// in alternating ways by oscillating between regular perspective and
// inverse perspective, changing which parts of the model appear
// bigger or smaller on the screen.
// Attach this script on the GameObject with the Camera component.
@unitycoder
unitycoder / BurstSDFGenerator.cs
Created January 1, 2025 21:33 — forked from runevision/BurstSDFGenerator.cs
Signed Distance Field generator for Unity with Burst support
/*
Based on the Anti-aliased Euclidean distance transform described by Stefan Gustavson and
Robin Strand. For further information, see https://contourtextures.wikidot.com/ and
https://web.archive.org/web/20220503051209/https://weber.itn.liu.se/~stegu/edtaa/
The algorithm is an adapted version of Stefan Gustavson's code, it inherits the copyright
statement below, which applies to this file only.
The rewrite with Unity Burst support makes the execution 40 times faster by default,
and 75 times faster if the passed in textures are both of type TextureFormat.RGBAFloat.
@unitycoder
unitycoder / TrackTargets.cs
Created November 22, 2024 07:55 — forked from RyanNielson/TrackTargets.cs
A orthographic camera script for Unity that keeps all targets in frame by adjusting orthographic size and camera position.
using UnityEngine;
public class TrackTargets : MonoBehaviour {
[SerializeField]
Transform[] targets;
[SerializeField]
float boundingBoxPadding = 2f;
@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 / 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 / CommentComponent.cs
Created November 4, 2024 21:03 — forked from yasirkula/CommentComponent.cs
Adding comments to Inspector via a component in Unity
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
[AddComponentMenu("Comment")]
public class CommentComponent : MonoBehaviour
{
#if UNITY_EDITOR
[SerializeField]
@unitycoder
unitycoder / TailwindColors.cs
Created October 29, 2024 16:08 — forked from FronkonGames/TailwindColors.cs
Tailwind color palette for Unity.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// _______ _ _ _ _ _____ _
// |__ __| (_) | (_) | | / ____| | |
// | | __ _ _| |_ ___ _ __ __| | | | ___ | | ___ _ __ ___
// | |/ _` | | \ \ /\ / / | '_ \ / _` | | | / _ \| |/ _ \| '__/ __|
// | | (_| | | |\ V V /| | | | | (_| | | |___| (_) | | (_) | | \__ \
// |_|\__,_|_|_| \_/\_/ |_|_| |_|\__,_| \_____\___/|_|\___/|_| |___/
//
// An expertly-crafted color palette out-of-the-box that is a great starting point if you don’t have your
// own specific branding in mind. Based on https://tailwindcss.com/docs/customizing-colors
@unitycoder
unitycoder / unity_6_empty_web_build.md
Created October 28, 2024 11:26 — forked from aras-p/unity_6_empty_web_build.md
Unity 6 "empty" web build file sizes

This short post by Defold people about "empty project build size" comparison between Defold, Unity and Godot (twitter, mastodon) sparked my interest.

It is curious that Godot builds seem to be larger than Unity? Would not have expected that! Anyway.

A way more extensive Unity "web" build comparison and analysics is over at https://github.com/JohannesDeml/UnityWebGL-LoadingTest but here are just my short notes in trying out Unity 6 (6.0.23 - Oct 2024).

Default (3D, URP) template