Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
// From: https://answers.unity.com/questions/801928/46-ui-making-a-button-transparent.html?childToView=851816
//
// @kurtdekker
//
// Touchable invisible non-drawing Graphic (usable with Buttons too):
//
// To make an invisible Button:
//
// 1. make a Button in the normal way
// 2. delete the "Text" GameObject which comes below a Button as standard
@unitycoder
unitycoder / CppBuildPreprocessing.cs
Created April 17, 2025 12:56 — forked from yCatDev/CppBuildPreprocessing.cs
Script that enables Full Generic Sharing by default for all builds for Unity 2021
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
public class CppBuildPreprocessing : IPreprocessBuildWithReport
{
public int callbackOrder
{
get { return 0; }
@unitycoder
unitycoder / InspectorLock.cs
Created April 13, 2025 18:15 — forked from adammyhre/InspectorLock.cs
Lock Inspector Icon and Transform Constrain Proportion Icon in Unity
using System.Reflection;
using UnityEditor;
using UnityEngine;
/// <summary>
/// Toggles the Inspector lock state and the Constrain Proportions lock state.
/// </summary>
public static class LockInspector {
static readonly MethodInfo flipLocked;
static readonly PropertyInfo constrainProportions;
@unitycoder
unitycoder / HeatmapCompute.compute
Created April 13, 2025 18:14 — forked from adammyhre/HeatmapCompute.compute
Compute Shader + Render Feature Heatmap
#pragma kernel CSMain
RWTexture2D<float> heatmapTexture;
float2 texSize;
StructuredBuffer<float2> enemyPositions;
int enemyCount;
[numthreads(8, 8, 1)]
void CSMain(uint3 id : SV_DispatchThreadID)

How to use GitHub releases as markdown image storage

I often uploaded images to GitHub issues and used their URLs in markdown files (such as README.md).
This method was convenient since it didn’t require adding the images to the repository, and each image had a unique URL.
However, in (probably) March 2025, GitHub changed their policy so that accessing images uploaded to issues now requires cookie-based authentication.
This applies even to images uploaded to issues in public repositories.

As a result, the benefit of 'anyone who knows the URL can access the image' has been lost.

@unitycoder
unitycoder / VoxelRay2D.js
Created April 10, 2025 19:28
unityscript 2d voxel travelsal
// from https://unitycoder.com/blog/2012/10/29/2d-raycasting-visibility-voxel-travelsal/
#pragma strict
// ORIGINAL SOURCE: http://dev.mothteeth.com/2011/11/2d-ray-casting-on-a-grid-in-as3/
// TileWorld.as - Lee Grey, November 2011
// Converted to Unity: http://unitycoder.com/blog
// ** remember to donate : ) **
// the mesh generation is based on this one: http://unitycoder.com/blog/2012/02/15/raycast-realtime-visibility-2-0/
@unitycoder
unitycoder / SpriteCustom.shader
Created April 10, 2025 13:10
spriteshader temp
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
Shader "Sprites/SpriteCustom"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
[HideInInspector] _RendererColor ("RendererColor", Color) = (1,1,1,1)
@unitycoder
unitycoder / DeviceAutoRotationIsOn.cs
Created April 6, 2025 11:25
Unity Android Check if Device has autorotation enabled
https://discussions.unity.com/t/responsive-ui-based-on-phone-orientation-change/932381/4
static bool DeviceAutoRotationIsOn()
{
#if UNITY_ANDROID && !UNITY_EDITOR
using (var unityPlayer = new AndroidJavaClass(“com.unity3d.player.UnityPlayer”))
{
var activity = unityPlayer.GetStatic(“currentActivity”);
var systemSettings = new AndroidJavaClass(“android.provider.Settings$System”);
var contentResolver = activity.Call(“getContentResolver”);
@unitycoder
unitycoder / Tooltip.cs
Created March 19, 2025 17:33
Move Screenspace UI (ugui) element near Mouse Position
tooltipRect.position = Input.mousePosition + (Vector3.right+Vector3.up) * 20;
// css waterdrop https://codepen.io/antoniasymeonidou/pen/QWqpoMJ
<div class='center'>
<div class='blob'></div></div>
body {
background: #e0e0e0;
}
.center {