Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
@unitycoder
unitycoder / Edge Detection.shader
Created December 20, 2024 18:20
Edge Detection shader
// https://ameye.dev/notes/edge-detection-outlines/
Shader "Custom/Edge Detection"
{
Properties
{
_OutlineThickness ("Outline Thickness", Float) = 1
_OutlineColor ("Outline Color", Color) = (0, 0, 0, 1)
}
SubShader
@unitycoder
unitycoder / win-commandline.md
Created December 19, 2024 08:45
windows cmd prompt commandline batch

install telnet

run as admin> dism /online /Enable-Feature /FeatureName:TelnetClient

@unitycoder
unitycoder / recyclebinsizes.ps1
Created December 17, 2024 13:19
PowerShell: Print out recycle bin sizes per user from C drive
# Prints out recycle bin sizes per user from C drive
# Ensure the script runs as Administrator
$recycleBinPath = "C:\`$Recycle.Bin" # Escape the `$` character
# Check for each user's Recycle Bin folder
Get-ChildItem -LiteralPath $recycleBinPath -Directory -Force | ForEach-Object {
$userSID = $_.Name
try {
# Resolve the SID to a username
@unitycoder
unitycoder / TriangularGridMesh.cs
Created December 15, 2024 20:55
terrain grid mesh generator
// https://discussions.unity.com/t/what-is-the-best-way-to-make-a-map-terrain-for-my-2d-game/1569621/5
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
[RequireComponent( typeof(MeshFilter) , typeof(MeshRenderer) )]
public class TriangularGridMesh : MonoBehaviour
{
[Header("Grid Settings")]
[SerializeField] float _gridTriangleLength = 1f;
@unitycoder
unitycoder / MotionFX.cs
Created December 11, 2024 20:17
MotionVector Effect: Object "disappears" when paused
// attach to main camera, BIRP
using UnityEngine;
[ExecuteInEditMode]
public class MotionFX : MonoBehaviour
{
public Material mat;
Camera cam;
@unitycoder
unitycoder / chatbot.py
Created December 2, 2024 22:33
llama-mesh: "Error Data incompatible with tuples format. Each message should be a list of length 2" (fixed test version)
"""gr.Chatbot() component."""
from __future__ import annotations
import inspect
import warnings
from collections.abc import Callable, Sequence
from dataclasses import dataclass, field
from pathlib import Path
from typing import (
@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 / 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
{