Skip to content

Instantly share code, notes, and snippets.

View sabresaurus's full-sized avatar

Sabresaurus sabresaurus

View GitHub Profile
@sabresaurus
sabresaurus / ConsoleCallStackHelper.cs
Last active May 2, 2020 09:56
Jump to file/line in the Unity console window callstack via this helper window
// MIT License
//
// Copyright (c) 2018 Sabresaurus
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@sabresaurus
sabresaurus / PrefabExplorer.cs
Last active July 22, 2022 03:16
An editor window that shows the full hierarchy of a prefab selected in the Project window, allowing you to select objects in a prefab beyond the top two levels (Unity's project view recurses only one deep)
// MIT License
//
// Copyright (c) 2019 Sabresaurus
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@sabresaurus
sabresaurus / BrushToCollider.cs
Last active December 8, 2020 19:28
Generates a box collider for the bounds of a brush or a convex mesh collider using the source polygons of a brush, also copies any referenced components to the built object. Note: you should disable collision on the source brush so that it isn't built into two separate colliders
#if UNITY_EDITOR
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Sabresaurus.SabreCSG;
using UnityEditor;
public class BrushToCollider : MonoBehaviour, IPostBuildListener
{
[SerializeField]
@sabresaurus
sabresaurus / BSPTreePostProcess.cs
Last active September 19, 2016 19:04
Makes generated mesh colliders compatible with SuperCharacterController (https://github.com/IronWarrior/SuperCharacterController)
#if UNITY_EDITOR
using UnityEngine;
using Sabresaurus.SabreCSG;
public static class BSPTreePostProcess
{
[PostProcessCSGBuild]
public static void OnPostProcessCSGBuild(Transform meshGroup)
{
if(meshGroup != null)
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using Type = System.Type;
public static class DuplicationUtility
{
public static GameObject DuplicateGameObject(GameObject source)
using UnityEngine;
using System.Collections.Generic;
using Sabresaurus.SabreCSG;
public class RuntimeCSGExample2 : MonoBehaviour
{
// Number of cells to create in the X and Z axis
[SerializeField]
int cellXCount = 10;
[SerializeField]
using UnityEngine;
using System.Collections.Generic;
using Sabresaurus.SabreCSG;
public class RuntimeCSGExample1 : MonoBehaviour
{
[SerializeField]
int count = 30; // Number of brushes to create
[SerializeField]
// Example of how to use AutoComponent ( https://gist.github.com/sabresaurus/339fcaab18ea7c6a2c53 )
[AutoComponent(RecursiveDirection.Up)]
Agent parentAgent;
[AutoComponent(RecursiveDirection.Down)]
MuzzleFlash muzzleFlash;
[AutoComponent(RecursiveDirection.Down)]
GunAnimator gunAnimator;
@sabresaurus
sabresaurus / AutoComponentAttribute.cs
Last active July 28, 2021 17:49
Automatic binding of component references
// MIT License
//
// Copyright (c) 2018 Sabresaurus
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions: