Skip to content

Instantly share code, notes, and snippets.

Avatar

Sabresaurus sabresaurus

View GitHub Profile
View DuplicationUtility.cs
#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)
View RuntimeCSGExample2.cs
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]
@sabresaurus
sabresaurus / BSPTreePostProcess.cs
Last active Sep 19, 2016
Makes generated mesh colliders compatible with SuperCharacterController (https://github.com/IronWarrior/SuperCharacterController)
View BSPTreePostProcess.cs
#if UNITY_EDITOR
using UnityEngine;
using Sabresaurus.SabreCSG;
public static class BSPTreePostProcess
{
[PostProcessCSGBuild]
public static void OnPostProcessCSGBuild(Transform meshGroup)
{
if(meshGroup != null)
View RuntimeCSGExample1.cs
using UnityEngine;
using System.Collections.Generic;
using Sabresaurus.SabreCSG;
public class RuntimeCSGExample1 : MonoBehaviour
{
[SerializeField]
int count = 30; // Number of brushes to create
[SerializeField]
@sabresaurus
sabresaurus / BrushToCollider.cs
Last active Aug 4, 2019
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
View BrushToCollider.cs
#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 / RagdollTest.cs
Created Sep 15, 2019
Toggle between animations and ragdoll
View RagdollTest.cs
// 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
Created Oct 16, 2019
Provides some stats (e.g. vertex count) about a bound mesh on a MeshFilter's inspector
View MeshFilterInspector.cs
// 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 / ConditionalVisibilityAttribute.cs
Created Oct 16, 2019
Allows you to restrict visibility of serialised fields based on an attribute, e.g. [ConditionalVisibility("siblingBool","True"),SerializeField] float foo = 0;
View ConditionalVisibilityAttribute.cs
// 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 / SharedPaletteData.cs
Created Nov 10, 2019
Part of SharedPaletteWindow, must be its own file so that Unity can serialize the scriptable object correctly.
View SharedPaletteData.cs
// 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:
View SharedPaletteWindow.cs
// 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:
You can’t perform that action at this time.