Skip to content

Instantly share code, notes, and snippets.

View JohannesDeml's full-sized avatar
🥽
Making Science

Johannes Deml JohannesDeml

🥽
Making Science
View GitHub Profile
@bgolus
bgolus / InfiniteGrid.shader
Last active June 12, 2024 18:15
Infinite Grid shader with procedural grid with configurable divisions and major and minor lines markings.
Shader "Unlit/InfiniteGrid"
{
Properties
{
[Toggle] _WorldUV ("Use World Space UV", Float) = 1.0
_GridScale ("Grid Scale", Float) = 1.0
_GridBias ("Grid Bias", Float) = 0.5
_GridDiv ("Grid Divisions", Float) = 10.0
_BaseColor ("Base Color", Color) = (0,0,0,1)
_LineColor ("Line Color", Color) = (1,1,1,1)
@BarelyAliveMau5
BarelyAliveMau5 / readme.md
Last active May 27, 2024 17:15
How to attach unity profiler to existing WebGL builds on Windows 11

Attaching the Unity profiler to WebGL builds on Windows 11

One of the biggest pains in Unity when developing for WebGL is that if you want to profile it, you have to use the "Build and Run" menu option to do it, while it works, it can be very inconvenient and waste a lot of time recompiling everything, in this brief tutorial I present a way of attaching the profiler without having to recompile everything.

Click here to see the TL;DR (Too long; Didn't Read™) step-by-step if you are not patient enough to read everything

Note: This entire procedure was only tested with Unity 2021.3.29f1. The procedure might be the same in newer versions, but in case it's not, refer below for how I discovered it for this version.

As of 2023-09-28, the Unity documentation states:

@siddolo
siddolo / unpack-unitywebdata1.0.py
Last active February 21, 2024 04:12
Unpack UnityWebData1.0 used in Unity WebGL games
#!/usr/bin/env python3
# Ref: https://github.com/HearthSim/UnityPack/issues/74
import sys
import os
from unitypack.utils import BinaryReader
SIGNATURE = 'UnityWebData1.0'
class DataFile:
@De-Panther
De-Panther / load_spectorjs_in_dev_console.js
Last active January 30, 2024 06:23
Code snippet for loading SpectorJS in WebGL page. Copy this code to the development console of a web page with WebGL content. Make sure that you are posting it in the right context(if the canvas is inside an iframe).
var newScript = document.createElement("script");
newScript.onload = function() {
var spector = new SPECTOR.Spector();
spector.displayUI();
};
document.head.appendChild(newScript);
newScript.src = "https://spectorcdn.babylonjs.com/spector.bundle.js";
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);
@HAliss
HAliss / ShaderTextureCombiner.cs
Created March 6, 2019 10:25
Texture combiner tool that uses a shader to combine different textures to specific color channels.
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
public class ShaderTextureCombiner : EditorWindow {
//Input textures
@handcircus
handcircus / unity.rb
Created October 19, 2018 13:51
Fastlane action to build Unity Project - now uses the project version to select from Hub versions (if applicable)
# Adapted from https://gist.github.com/dddnuts/522302dc0b787896ebd103542372f9c1
module Fastlane
module Actions
class UnityAction < Action
def self.run(params)
projectVersionFilePath="#{params[:project_path]}/ProjectSettings/ProjectVersion.txt"
UI.message "Checking project version at #{projectVersionFilePath}"
if !File.exist?(projectVersionFilePath)
UI.error("Can't find project version file")
@phi-lira
phi-lira / UniversalPipelineTemplateShader.shader
Last active June 15, 2024 02:13
Template shader to use as guide to create Universal Pipeline ready shaders. This shader works with Universal Render Pipeline 7.1.x and above.
// When creating shaders for Universal Render Pipeline you can you the ShaderGraph which is super AWESOME!
// However, if you want to author shaders in shading language you can use this teamplate as a base.
// Please note, this shader does not necessarily match perfomance of the built-in URP Lit shader.
// This shader works with URP 7.1.x and above
Shader "Universal Render Pipeline/Custom/Physically Based Example"
{
Properties
{
// Specular vs Metallic workflow
[HideInInspector] _WorkflowMode("WorkflowMode", Float) = 1.0
@smkplus
smkplus / UnityShaderCheatSheet.md
Last active May 7, 2024 07:34
Controlling fixed function states from materials/scripts in Unity

16999105_467532653370479_4085466863356780898_n

Shader "MaterialPropertyDrawer"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
 
[HideInInspector] _MainTex2("Hide Texture", 2D) = "white" {}
@tomkail
tomkail / DefaultAssetEditor.cs
Last active September 16, 2022 15:02
Draws inspectors for any file type Unity doesn't draw by default
/// Used to draw custom inspectors for unrecognised file types, which Unity imports as "DefaultAsset"
/// To do this, create a new editor class extending DefaultAssetInspector
/// Return true in the IsValid function if the file extension of the file matches the type you'd like to draw.
/// The DefaultAssetEditor class will then hold a reference to the new instance of your editor class and call the appropriate methods for drawing.
/// An example can be found at the bottom of the file.
using UnityEngine;
using UnityEditor;
using System;
using System.IO;