Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
@unitycoder
unitycoder / UnityGraphicsBullshit.cs
Created August 19, 2022 07:56 — forked from JimmyCushnie/UnityGraphicsBullshit.cs
Exposes some Unity URP graphics settings that are (for some stupid fucking bullshit reason) private.
using System.Reflection;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using ShadowResolution = UnityEngine.Rendering.Universal.ShadowResolution;
/// <summary>
/// Enables getting/setting URP graphics settings properties that don't have built-in getters and setters.
@unitycoder
unitycoder / UnityStencilMask.shader
Created August 19, 2022 12:00 — forked from ewandennis/UnityStencilMask.shader
A simple stencil buffer masking shader for Unity
Shader "Custom/StencilMask" {
Properties {
_StencilMask("Stencil mask", Int) = 0
}
SubShader {
Tags {
"RenderType" = "Opaque"
"Queue" = "Geometry-100"
}
@unitycoder
unitycoder / TriplanarWorld.shader
Created August 22, 2022 07:46 — forked from radiatoryang/TriplanarWorld.shader
a triplanar / procedural UV / world space UV shader for Unity, cobbled together bits from @quickfingerz and @Farfarer
Shader "Tri-Planar World" {
Properties {
_Side("Side", 2D) = "white" {}
_Top("Top", 2D) = "white" {}
_Bottom("Bottom", 2D) = "white" {}
_SideScale("Side Scale", Float) = 2
_TopScale("Top Scale", Float) = 2
_BottomScale ("Bottom Scale", Float) = 2
}
@unitycoder
unitycoder / Comment.cs
Created September 8, 2022 15:17 — forked from apkd/Comment.cs
Use this component to leave comments to other developers (and yourself) on GameObjects, prefabs, etc. Double-click the text area to edit.
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Callbacks;
#endif
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using S = UnityEngine.SerializeField;
@unitycoder
unitycoder / CloneAndFlipTriangles.cs
Created September 22, 2022 10:53 — forked from kurtdekker/CloneAndFlipTriangles.cs
Clones and flips a piece of geometry, optionally using another material
using UnityEngine;
// @kurtdekker
//
// Place on a MeshFilter / MeshRenderer GameObject.
//
// This will:
// - duplicate the entire GameObject via Instantiate
// (and obviously its children; those are ignored!)
// - parent it to the same place the original was
@unitycoder
unitycoder / MakeGeometryDoubleSided.cs
Created September 22, 2022 10:53 — forked from kurtdekker/MakeGeometryDoubleSided.cs
Makes geometry double-sided by re-winding copies of each triangle to face the other way
using UnityEngine;
// @kurtdekker - quick double-siding mechanism.
//
// Place or add this Component to things with at
// least a MeshFilter on them.
//
// Presently only for single-submesh geometry.
[RequireComponent( typeof( MeshFilter))]
@unitycoder
unitycoder / unity3d-assetstore-publisher-feed.php
Created October 3, 2022 11:00 — forked from jgraup/unity3d-assetstore-publisher-feed.php
PHP - Unity3D Asset Store Publisher Feed. You must supply your own secret key to use this, a key is generated per publisher at https://publisher.assetstore.unity3d.com/info.html
<?php
include_once ( 'unity3d-assetstore.php' );
// Doesn't matter what is used for the publisher name,
// the key still points to only one publisher.
$authArray = array (
'publisher' => '{PUBLISHER_NAME}'
'key' => '{PUBLISHER_KEY}',
);
@unitycoder
unitycoder / HowToProfilerBuildTime.txt
Created October 9, 2022 11:42 — forked from phi-lira/HowToProfilerBuildTime.txt
How to profile build time for a Unity project
1) Enable Profiler in OnPreprocessBuild like following:
public void OnPreprocessBuild(BuildReport report)
{
Profiler.enabled = true;
Profiler.enableBinaryLog = true;
Profiler.logFile = "profilerlog.raw";
Debug.Log("Enabling Profiler");
}
2) Disable Profiler in OnPostProcessBuild
3) Now put Profiler.Begin/EndSample in the desired code.
@unitycoder
unitycoder / MonoExtensions.cs
Created October 26, 2022 13:04 — forked from mstfmrt07/MonoExtensions.cs
A simple C# extension to easily create WaitForSeconds coroutines
using System.Collections;
using UnityEngine;
using UnityEngine.Events;
public static class MonoExtensions
{
public static Coroutine Wait(this MonoBehaviour mono, float delay, UnityAction action)
{
return mono.StartCoroutine(ExecuteAction(delay, action));
}
Shader "Name" {
Properties {
_Name ("display name", Range (min, max)) = number
_Name ("display name", Float) = number
_Name ("display name", Int) = number
_Name ("display name", Color) = (number,number,number,number)
_Name ("display name", Vector) = (number,number,number,number)