Skip to content

Instantly share code, notes, and snippets.

@twobob
twobob / A set of Unity3D extension methods
Created August 18, 2018 18:28 — forked from omgwtfgames/A set of Unity3D extension methods
Some useful extension method for Unity3D
A collection of useful C# extension methods for the Unity engine.
@twobob
twobob / Vector2Int.cs
Created August 22, 2018 10:56
Unity 5.6 Vector2Int.cs PolyFill
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using System.Runtime.InteropServices;
using UnityEngine.Scripting;
namespace UnityEngine
{
@twobob
twobob / MeshSaverEditor.cs
Last active August 22, 2018 16:25
Various editor and contextual methods to save procedurally generated meshes. "Save Mesh..." will insert GUID and "Just save" a large batch with no effort
using UnityEditor;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public static class MeshSaverEditor {
[MenuItem("Tools/MeshFilter/Save Mesh...")]
public static void SaveMeshInPlace (MenuCommand menuCommand) {
@twobob
twobob / Dungeon.cs
Created August 25, 2018 23:16 — forked from xDavidLeon/Dungeon.cs
Zelda Dungeon Generator for Unity 3D
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Dungeon : MonoSingleton<Dungeon>
{
[System.Serializable]
public class Position
{
public int x = 0;
@twobob
twobob / ToonDeferredShading2017.shader
Created August 25, 2018 23:18 — forked from xDavidLeon/ToonDeferredShading2017.shader
Unity 5.6 Deferred Cel Shading Modification
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
// Modifications by David Leon. Copyright (c) 2017 Lince Works SL. MIT license (see license.txt)
Shader "ToonDeferredShading2017" {
Properties {
_LightTexture0 ("", any) = "" {}
_LightTextureB0 ("", 2D) = "" {}
_ShadowMapTexture ("", any) = "" {}
_SrcBlend ("", Float) = 1
_DstBlend ("", Float) = 1
@twobob
twobob / gist:ae7eef02c6946ee6c09e47224aab81d6
Last active February 7, 2021 02:09
patching dll's for rimworld
get dnspy https://github.com/0xd4d/dnSpy/releases
I used https://github.com/dnSpy/dnSpy/releases/download/v6.1.8/dnSpy-net-win64.zip
* run it, and drop your Assembly-CSharp dll on it
* usually in "c:\Program Files (x86)\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp.dll"
* expand the tree Assembly-Csharp (1.2.7705.251110) -> {} Rimworld -> LordJob_PrisonBreak
* right click the "CanOpenAnyDoor" method name in th code on the right hand side pane and choose -> Edit method
using UnityEngine;
public class SimpleSoundManager:MonoBehaviour {
// Audio source
private AudioSource musicSrc;
private AudioSource effectSrc;
// Instance variable
private static SimpleSoundManager instance;
// Instance
@twobob
twobob / ZoomToTarget.cs
Created September 6, 2018 08:46
Horrible code to reverse explode prefabs
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TransformWithStoredPositions {
public Vector3 intendedLocationForTransform { get; set; }
@twobob
twobob / OnClickManageBuildings.cs
Created September 6, 2018 08:48
basic bitch click thingy for prefabs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OnClickManageBuilding : MonoBehaviour {
public GameObject buildingPrefab;
public Material selectedMaterial;
@twobob
twobob / MeshCut.cs
Created September 7, 2018 08:28 — forked from alexcmd/MeshCut.cs
Mesh cut algorithm for Unity
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class MeshCut
{
private static Plane blade;
private static Transform victim_transform;
private static Mesh victim_mesh;