Skip to content

Instantly share code, notes, and snippets.

View sabresaurus's full-sized avatar

Sabresaurus sabresaurus

View GitHub Profile
@sabresaurus
sabresaurus / PaletteWindow.cs
Last active September 27, 2023 19:50
Palette window with drag-drop boxes that you can drag common objects onto such as scenes, materials, prefabs to easily access them later (From SabreCSG originally)
// MIT License
//
// Copyright (c) 2021 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 / HierarchyEmptyObjectDisplay.cs
Created December 3, 2020 12:20
Shows empty game objects in the hierarchy
// MIT License
//
// Copyright (c) 2020 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 / IMGUIInjectionProofOfConcept.cs
Created November 17, 2022 00:28
Adds custom IMGUI to existing host views (such as Unity's built in windows)
// MIT License
//
// Copyright (c) 2022 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 / MeshFilterInspector.cs
Last active January 9, 2022 00:24
Provides some stats (e.g. vertex count) about a bound mesh on a MeshFilter's inspector
// MIT License
//
// Copyright (c) 2021 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 / 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:
// 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 / DisplaySpriteOutline.cs
Created September 5, 2020 19:27
Getting Unity Sprite Outline
using UnityEditor;
using UnityEngine;
public class DisplaySpriteOutline : MonoBehaviour
{
[SerializeField] private Sprite sprite;
private void OnDrawGizmos()
{
TextureImporter textureImporter = (TextureImporter) AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(sprite.texture));
@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: