Skip to content

Instantly share code, notes, and snippets.

Avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
@unitycoder
unitycoder / UnityUtils.cs
Created Apr 14, 2021 — forked from stonstad/UnityUtils.cs
Locate Unity Assets Which Contain Broken References
View UnityUtils.cs
using System;
using System.IO;
using UnityEditor;
using UnityEngine;
using System.Linq;
using System.Threading.Tasks;
public class UnityUtils: MonoBehaviour
{
[MenuItem("Tools/Find Broken GUIDs")]
@unitycoder
unitycoder / CornerCheat.cs
Created Apr 7, 2021 — forked from grapefrukt/CornerCheat.cs
Makes a CircleCollider2D slide smoothly along the inner edge of a rounded EdgeCollider2D
View CornerCheat.cs
using UnityEngine;
public class CornerCheat : MonoBehaviour {
public CircleCollider2D circle;
public Rigidbody2D body;
EdgeCollider2D edge;
[Range(0, .2f)] public float distanceThreshold = .03f;
[Range(0, 1)] public float dotThreshold = .96f;
@unitycoder
unitycoder / webglcompress.bat
Last active Apr 7, 2021
Unity Compress WebGL Build Manually from Commandline (Brotli)
View webglcompress.bat
echo off
REM add egg path
set PYTHONPATH=D:/Program Files/Unity2019_4/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Brotli/dist/Brotli-0.4.0-py2.7-win-amd64.egg
REM rename uncompressed data files (because brotli cannot overwrite same file that its packing)
move /Y "F:\Your\Project\Build\uncompressed.wasm.framework.unityweb" "F:\Your\Project\Build\uncompressed.wasm.framework.unityweb2"
move /Y "F:\Your\Project\Build\uncompressed.wasm.code.unityweb" "F:\Your\Project\Build\uncompressed.wasm.code.unityweb2"
move /Y "F:\Your\Project\Build\uncompressed.data.unityweb" "F:\Your\Project\Build\uncompressed.data.unityweb2"
REM compress
@unitycoder
unitycoder / Bake Vertex Color Map.shader
Created Apr 6, 2021
bake vertex color from mesh to texture
View Bake Vertex Color Map.shader
Shader "Bake Vertex Color Map"
{
SubShader
{
Pass
{
ZTest Off
ZWrite Off
Cull Off
CGPROGRAM
@unitycoder
unitycoder / unity-openxr.md
Last active Apr 6, 2021
unity openxr notes and tips
View unity-openxr.md
View RtpPacket.cs
// https://stackoverflow.com/a/61267482/5452781
// ffplay rtp://0.0.0.0:your_port
using System;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using UnityEngine;
public static class RtpPacket
@unitycoder
unitycoder / GPU Compute Model Terminology.md
Last active Mar 29, 2021
GPU Compute Model Terminology / Quick Reference / CheatSheet
View GPU Compute Model Terminology.md

from Landom Thomas https://landonthomas.net/docs/gpu_compute_model_terms_quick_ref.pdf

Compute Abstraction Hierarchy Microsoft HLSL Khronos GLSL Khronos OpenCL C Nvidia,CUDA C AMD,HIP Apple,MSL
Entire Kernel/Shader Compute Space Dispatch Dispatch, Compute Space NDRange, Index Space Grid Grid Grid
Major Compute Group Group, Thread Group Workgroup, Local Workgroup Work-group Block, Thread Block Block Threadgroup
Minor Compute Group (& Device Minor SIMD Unit) Wave Subgroup Sub-group Warp Wavefront, Wave, Warp SIMD-group
Quad Compute Object Quad Wave Subgroup Quad ? Quad Quad Quad-group
Single Compute Object Thread Invocation Work-item Thread Thread Thread
@unitycoder
unitycoder / SineWave.cs
Created Mar 26, 2021
OnAudioFilterRead generate sinewave
View SineWave.cs
// https://forum.unity.com/threads/onaudiofilterread-question.170273/#post-1164846
using UnityEngine;
using System; // Needed for Math
public class SineWave : MonoBehaviour
{
// un-optimized version
public double frequency = 440;
public double gain = 0.05;
private double increment;
@unitycoder
unitycoder / ToggleGoogleVROnOff.cs
Created Mar 22, 2021
toggle between 2d and Google Cardboard (2020 Unity XR)
View ToggleGoogleVROnOff.cs
https://forum.unity.com/threads/toggle-between-2d-and-google-cardboard.902378/#post-6959573
Coroutine StartVR()
{
return StartCoroutine(startVRRoutine());
IEnumerator startVRRoutine()
{
// Add error handlers for both Instance and Manager
var xrManager = XRGeneralSettings.Instance.Manager;
if (!xrManager.isInitializationComplete)
@unitycoder
unitycoder / TriangleDebugLines.cs
Created Mar 19, 2021
Draw Debug Lines on Mesh Triangle
View TriangleDebugLines.cs
// related topic https://forum.unity.com/threads/create-grid-in-mesh-triangle.1078211/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TriangleDebugLines : MonoBehaviour
{
void Start()
{