Skip to content

Instantly share code, notes, and snippets.

View Invertex's full-sized avatar
👁️‍🗨️

Dabbles in too many things Invertex

👁️‍🗨️
View GitHub Profile
@Invertex
Invertex / StreamingAudioPlayer.cs
Last active May 11, 2023 12:05
Unity streaming audio playback example
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;
namespace Invertex.Unity.Audio
{
/// <summary>
/// Component that allows playback of an audio file from a server or locally that begins playing before the file is completely downloaded.
/// </summary>
public class StreamingAudioPlayer : MonoBehaviour
@popcron
popcron / CustomPlayBehaviour.cs
Last active May 26, 2022 01:31
Custom code before play
using System;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
namespace blablalblalmao
{
[InitializeOnLoad]
@Invertex
Invertex / CustomHoldingInteraction.cs
Last active May 16, 2024 09:56
Unity New Input System custom Hold "Interaction" where the .performed callback is constantly triggered while input is held.
using UnityEngine;
using UnityEngine.InputSystem;
//!!>> This script should NOT be placed in an "Editor" folder. Ideally placed in a "Plugins" folder.
namespace Invertex.UnityInputExtensions.Interactions
{
//https://gist.github.com/Invertex
/// <summary>
/// Custom Hold interaction for New Input System.
/// With this, the .performed callback will be called everytime the Input System updates.
@primaryobjects
primaryobjects / hotspot-keep-alive.ps1
Last active June 24, 2024 13:30
Script to Enable Windows 10 Mobile Hotspot Automatically After Reboot
# https://superuser.com/a/1434648
Add-Type -AssemblyName System.Runtime.WindowsRuntime
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]
Function Await($WinRtTask, $ResultType) {
$asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
$netTask = $asTask.Invoke($null, @($WinRtTask))
$netTask.Wait(-1) | Out-Null
$netTask.Result
@aras-p
aras-p / DebugNode.hlsl
Created January 3, 2020 10:37
"Print a value" custom function node code for Unity ShaderGraph
// Quick try at doing a "print value" node for Unity ShaderGraph.
// Tested on Unity 2019.2.17 with ShaderGraph 6.9.2.
//
// Use with CustomFunction node, with two inputs:
// - Vector1 Value, the value to display,
// - Vector2 UV, the UVs of area to display at.
// And one output:
// - Vector4 Color, the color.
// Function name is DoDebug.
@HungryProton
HungryProton / shader_cache.gd
Last active June 23, 2024 01:32
Godot shader cache hack
extends Spatial
var _materials := []
var _process_materials := []
var _count := 0
func _ready() -> void:
_find_all_materials("res://")
print(_process_materials)
using UnityEngine;
public class MeshBlit : MonoBehaviour
{
public RenderTexture rt;
public Mesh mesh;
public Material material;
public Vector3 meshPosition = new Vector3(0.5f, 0.5f, -1);
@bgolus
bgolus / StableConstantTextureSize.shader
Created April 6, 2019 18:50
Visually stable constant screen space sized texture shader for Unity
Shader "Unlit/Stable Constant Texture Size"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
@LotteMakesStuff
LotteMakesStuff / PlayerLoop.cs
Last active March 25, 2024 02:38
Player Loop Visualizer: Built to explore the new PlayerLoopSystem api in Unity 2018.1b2. This tool shows you all the PlayerLoop systems that unity uses to update a frame, and demos how to add your own and even remove systems from the player loop. For more info see the patreon post https://www.patreon.com/posts/unity-2018-1-16336053
// Put this in an editor folder
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.Experimental.LowLevel;
using UnityEngine.Profiling;
@thefranke
thefranke / LegacyTransparencyLM.shader
Created March 14, 2017 09:09
Custom transmission texture in Unity
Shader "Transparent/Transmission"
{
Properties
{
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_TransparencyLM("Transmission", 2D) = "white" {}
}
SubShader