Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
@unitycoder
unitycoder / TMP_InputField.cs
Created February 13, 2025 07:39 — forked from nikescar1/TMP_InputField.cs
Since TMP_InputField is essentially unusable with gamepad and keyboard navigation, I upgraded them to work better (don't start editing on select and added OnFocus event)
//#define TMP_DEBUG_MODE
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Text;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.UI;
@unitycoder
unitycoder / TransformEditor.cs
Created February 12, 2025 12:54 — forked from GhatSmith/TransformEditor.cs
Custom inspector for Transform component. Add buttons to reset, copy, paste Transform values. Add context menu to round or truncate values.
using UnityEngine;
using UnityEditor;
namespace OddTales.Framework.Core.EditorExtension
{
/// <summary>
/// Custom inspector for Transform component. Using only DrawDefaultInspector would give different display.
/// Script based on Unity wiki implementation : https://wiki.unity3d.com/index.php/TransformInspector
/// Buttons to reset, copy, paste Transform values.
@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]