Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
@unitycoder
unitycoder / XRPluginManagementSettings.cs
Created February 21, 2024 18:49 — forked from korinVR/XRPluginManagementSettings.cs
Enable and disable XR Plug-in Management plugins
using System;
using UnityEditor;
using UnityEditor.XR.Management;
using UnityEditor.XR.Management.Metadata;
using UnityEngine;
namespace FrameSynthesis.XR
{
// ref. https://docs.unity3d.com/Packages/com.unity.xr.management@4.1/manual/EndUser.html
public static class XRPluginManagementSettings
@unitycoder
unitycoder / install_obb.sh
Created February 12, 2024 09:00 — forked from DanielJenkyn/install_obb.sh
Script to install .apk and .obb (Split binary) onto Android device
#!/bin/bash
project_name= com.jenkyncorp.bestapp
reinstall=
# Takes the most recent .apk and .obb (If you have multiple files)
OBB=$(ls -t *.obb | head -n1)
APK=$(ls -t *.apk | head -n1)
while [ "$1" != "" ]; do
@unitycoder
unitycoder / UnitypackageExtractor.cs
Created December 17, 2023 12:42 — forked from yasirkula/UnitypackageExtractor.cs
Extract a .unitypackage to any directory (even outside the project folder) from within Unity
#define STOP_EXTRACTION_WHEN_WINDOW_CLOSED
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Text;
using System.Threading;
using UnityEditor;
@unitycoder
unitycoder / MathUtil.cs
Created December 8, 2023 12:01 — forked from SaffronCR/MathUtil.cs
[C#, Unity] Math Helper Class.
using System.Runtime.InteropServices;
using UnityEngine;
public class MathUtil
{
// Evil floating point bit level hacking.
[StructLayout(LayoutKind.Explicit)]
private struct FloatIntUnion
{
[FieldOffset(0)]
@unitycoder
unitycoder / Lightbeam.shader
Created December 6, 2023 09:17 — forked from ArieLeo/Lightbeam.shader
UDN Lightbeam Shader converted to Unity
Shader "Lightbeam/Lightbeam" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_Width ("Width", Float) = 8.71
_Tweak ("Tweak", Float) = 0.65
}
SubShader {
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True"}
Pass {
@unitycoder
unitycoder / Outline.shader
Created December 6, 2023 09:17 — forked from ArieLeo/Outline.shader
Wide Outlines Renderer Feature for URP and ECS/DOTS/Hybrid Renderer
// Original shader by @bgolus, modified slightly by @alexanderameye for URP, modified slightly more
// by @gravitonpunch for ECS/DOTS/HybridRenderer.
// https://twitter.com/bgolus
// https://medium.com/@bgolus/the-quest-for-very-wide-outlines-ba82ed442cd9
// https://alexanderameye.github.io/
// https://twitter.com/alexanderameye/status/1332286868222775298
Shader "Hidden/Outline"
{
Properties
@unitycoder
unitycoder / RenderObjectsPass.cs
Created December 6, 2023 09:17 — forked from ArieLeo/RenderObjectsPass.cs
Unity URP sample -RenderObjects's RenderPass
using System.Collections.Generic;
using UnityEngine.Rendering.Universal;
using UnityEngine.Rendering;
using UnityEngine.Scripting.APIUpdating;
namespace UnityEngine.Experimental.Rendering.Universal
{
[MovedFrom("UnityEngine.Experimental.Rendering.LWRP")] public class RenderObjectsPass : ScriptableRenderPass
{
RenderQueueType renderQueueType;
@unitycoder
unitycoder / Usage.cs
Created December 6, 2023 09:16 — forked from ArieLeo/Usage.cs
DrawMeshInstancedIndirect with ShaderGraph and URP
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
class Render : MonoBehaviour
{
struct DrawData
{
public Vector3 Pos;
public Quaternion Rot;
@unitycoder
unitycoder / gist:b1a9fdbae5e35e70a52608ea776d59f8
Created November 26, 2023 18:37 — forked from texone/gist:66a46554a6fbda50ccc9831561e4037f
Unity lockless (no GPU readback) marching cubes via Graphics.DrawProceduralIndirect - some slight faffing because compute shader must append full triangle (3 verts) at a time to render correctly, but this means the appendbuffer count is 3 times smaller than it needs to be, so we have to invoke a very short compute shader (FixupIndirectArgs) just…
MarchingCubesGPU.cs:
...
// DrawProceduralIndirect
ComputeBuffer argsBuffer;
[StructLayout(LayoutKind.Sequential)]
struct DrawCallArgBuffer
{
public const int size =
sizeof(int) +
sizeof(int) +