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 / AutoMaskHumanoidRigsProcessor.cs
Last active January 23, 2024 13:48
Automatically creates and applies a full mask to all clips in a Humanoid rig so that all parts of the animation are maintained.
using UnityEngine;
using UnityEditor;
using System.Linq;
namespace Invertex.Unity.Editor.Importing
{
/// <summary>
/// This script will automatically generate an AvatarMask that will enable a Humanoid animation to animate all parts of your asset.
/// It will assign it to every clip in a new asset or every existing clip on an asset.
/// USAGE: Place in an "Editor" folder somewhere in your assets.
@Invertex
Invertex / GameWindowHideUIUntilPlay.cs
Last active April 5, 2023 04:20
Unity - Auto-hide UI in GameView when not in play mode.
using UnityEngine;
//Place on Camera you want to stop rendering UI while out of Play mode.
//UI Canvas needs to have its "Render Mode" be ing either "World Space" or "Screen Space - Camera" for this to work.
[ExecuteAlways, ExecuteInEditMode, RequireComponent(typeof(Camera))]
public class GameWindowHideUIUntilPlay : MonoBehaviour
{
void OnEnable()
{
ToggleUIDisplay(Application.isPlaying);
@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
@Invertex
Invertex / Physics2DExtensions.cs
Created January 22, 2023 10:54
Extension methods for modify the PhysicsMaterial2D on Rigidbody2D/Collider2D components without it affecting other objects.
using UnityEngine;
namespace Invertex.Unity2D.Physics
{
public static class Physics2DExtensions
{
//Example Usage: rigidbody.ModifyUniquePhysicsMaterial2D(0.5f, 0.2f);
/// <summary>
/// Sets the given values on the PhysicsMaterial2D of the Rigidbody. If a material unique to this object doesn't exist, a new one will be created just for it.
@Invertex
Invertex / Sprites-Default-ZWrite.shader
Created October 12, 2021 05:05
Version of Unity Sprites/Default shader that does ZWrite so sprites can clip eachother.
// Version of Unity Sprites/Default shader that does ZWrite
Shader "Invertex/Sprites/Default-ZWrite"
{
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)
[HideInInspector] _Flip ("Flip", Vector) = (1,1,1,1)
@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.
@Invertex
Invertex / EditorInputCapture.cs
Last active March 12, 2024 15:27
Unity Editor Input example using the New Input System
using UnityEditor;
using UnityEngine;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
#endif
//Simple Editor-side New Input System capture
namespace Invertex.UnityEditor.InputTools
{
[InitializeOnLoad]