Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
✅
‏‏‎

mika unitycoder

✅
‏‏‎
View GitHub Profile
@unitycoder
unitycoder / UnityForumBoardSearchHelper.js
Last active June 15, 2023 16:52
Unity Forum Search : AutoSelect current board item inside Search select list (based on referrer url)
// ==UserScript==
// @name Unity Forum Search : AutoSelect current board item inside Search select list (based on referrer url)
// @namespace https://unitycoder.com
// @version 1
// @include https://forum.unity.com/search/?type=post
// @grant none
// ==/UserScript==
// more info https://unitycoder.com/blog/2021/05/26/unity-forums-auto-select-current-subforum-in-search-greasemonkey-script/
// get referring board url
@unitycoder
unitycoder / UnlitAlphaCutoutColor.shader
Created May 26, 2021 06:59
Unlit Alpha Cutout Color Shader
Shader "Unlit/Transparent Cutout Color"
{
Properties{
_MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff("Alpha cutoff", Range(0,1)) = 0.5
_Color("Color",Color) = (1,1,1,1)
}
SubShader{
Tags {"Queue" = "AlphaTest" "IgnoreProjector" = "True" "RenderType" = "TransparentCutout"}
LOD 100
@unitycoder
unitycoder / floatArrayTest.cs
Created May 26, 2021 05:48
Return a float/double array from jslib to Unity
// https://forum.unity.com/threads/return-a-float-double-array-from-jslib-to-unity.1115686/#post-7176607
using AOT;
using System;
using System.Runtime.InteropServices;
using UnityEngine;
 
public class floatArrayTest : MonoBehaviour
{
    [DllImport("__Internal")]
    private static extern IntPtr JS_FloatArrayTest();
@unitycoder
unitycoder / ComputeShaderCompress.compute
Created May 25, 2021 06:02
Runtime texture compression using compute shader
// https://zhuanlan.zhihu.com/p/327045410
#include "ETCCompress.hlsl"
#include "BCCompress.hlsl"
#pragma multi_compile _COMPRESS_BC3 _COMPRESS_ETC2
#pragma kernel CSMain
RWTexture2D<uint4> Result;
Texture2D<float4> RenderTexture0;
SamplerState samplerRenderTexture0;
uint4 DestRect;
[numthreads(8, 8, 1)]
@unitycoder
unitycoder / mywindow.asm
Created May 23, 2021 08:57
Simple ASM Windows App
// https://www.youtube.com/watch?v=b0zxIfJJLAY
// https://pastebin.com/Pmvr4r1S
;-------------------------------------------------------------------------------------------------------------------
; Hello, Windows! in x86 ASM - (c) 2021 Dave's Garage - Use at your own risk, no warranty!
;-------------------------------------------------------------------------------------------------------------------
; Compiler directives and includes
.386 ; Full 80386 instruction set and mode
@unitycoder
unitycoder / DualShock2HIDInputReport.cs
Created May 21, 2021 06:24
How do you read from the raw HID
// https://forum.unity.com/threads/how-do-you-read-from-the-raw-hid.690196/#post-6562759
using UnityEngine;
using UnityEditor;
using System.Runtime.InteropServices;
using UnityEngine.InputSystem.Layouts;
using UnityEngine.InputSystem.LowLevel;
using UnityEngine.InputSystem.Utilities;
 
namespace UnityEngine.InputSystem.LowLevel
{
@unitycoder
unitycoder / MirrorReflection.cs
Created May 19, 2021 06:15
steamvr mirror reflection in vr
// https://forum.unity.com/threads/mirror-reflections-in-vr.416728/#post-7087360
// original source from: http://wiki.unity3d.com/index.php/MirrorReflection4
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Valve.VR;
// This is in fact just the Water script from Pro Standard Assets,
// just with refraction stuff removed.
[ExecuteInEditMode] // Make mirror live-update even when not in play mode
@unitycoder
unitycoder / learn-unity-links.md
Last active August 20, 2026 15:25
Learn Unity Resources
@unitycoder
unitycoder / Whats wrong with Microsoft Authenticator.md
Created May 14, 2021 07:41
Whats wrong with Microsoft Authenticator

Security

  • Displays your screenlock pattern after entering it! (it wont disappear until you click continue, why it is even drawing that visible line?)

UX

  • After scanning new QR code it suddenly asks, "Would you recommend Authenticator" (as if its related to that scan)

BUGS

  • When press NO, for "would you recommend", clicking "send feedback" crashes the app!
@unitycoder
unitycoder / IsEditor.cs
Created May 11, 2021 11:16
How to know if a script is running inside Unity Editor when using Device Simulator?
// https://forum.unity.com/threads/how-to-know-if-a-script-is-running-inside-unity-editor-when-using-device-simulator.921827/#post-7129751
#if UNITY_EDITOR
if (Application.isEditor)
Debug.Log("Editor");
else
Debug.Log("Editor Simulator");
#endif