Skip to content

Instantly share code, notes, and snippets.

View Naphier's full-sized avatar

Sean Mann Naphier

View GitHub Profile
using UnityEngine;
using UnityEditor;
public class MasterCam : ScriptableObject
{
[MenuItem("GameObject/MasterCam/Set all cameras")]
static void CopyToAllCameras()
{
bool go = EditorUtility.DisplayDialog("MasterCam", "***This operations cannot be undone!***\nThis will copy the current scene's camera settings to every camera in every scene included in Build Settings.", "OK", "Cancel");
if (go)
@Naphier
Naphier / ShowColliders.cs
Created October 11, 2015 16:18
Shows all active colliders in a scene with different color for triggers vs colliders.
using UnityEngine;
public class ShowColliders : MonoBehaviour
{
public enum collidertype
{ All, TriggersOnly, CollidersOnly, None}
public collidertype show = collidertype.All;
public Color colliderColor = Color.yellow;
public Color triggerColor = Color.blue;
@Naphier
Naphier / ShowRotated.cs
Created October 11, 2015 16:20
Draws rotated transform handles for a game object
using UnityEngine;
public class ShowRotated : MonoBehaviour
{
public void OnDrawGizmos()
{
Gizmos.matrix = transform.localToWorldMatrix;
Gizmos.color = Color.blue;
Gizmos.DrawLine(Vector3.zero, Vector3.forward * 10f);
Gizmos.color = Color.red;
@Naphier
Naphier / WeightedRandom.cs
Created October 11, 2015 16:27
Class to get a weighted random number
using UnityEngine;
namespace NG
{
/// <summary>
/// Gets a weighted random number
/// Usage
/// float y = WeightedRandom.GetRandomValue(
/// new WeightedRandom.RandomSelection(100f, 80f , 0.20f),
/// new WeightedRandom.RandomSelection(80f, 60f, 0.40f),
@Naphier
Naphier / ParticleSystemSpeed.cs
Created October 11, 2015 16:27
Simple script to set the playback speed of a particle system on application start Allows you to also lock that speed so it can't be changed by another script.
using UnityEngine;
/// <summary>
/// Simple script to set the playback speed of a particle system on application start
/// Allows you to also lock that speed so it can't be changed by another script.
/// </summary>
[RequireComponent(typeof(ParticleSystem))]
public class ParticleSystemSpeed : MonoBehaviour
{
@Naphier
Naphier / DebugToFile.cs
Created October 11, 2015 16:30
Simple debugging to file. Useful for creating CSV files where you want to look at variable changes over each frame.
using System.Collections.Generic;
using System.IO;
using UnityEngine;
namespace NG
{
public class DebugToFile
{
public static List<string> dOut = new List<string>();
@Naphier
Naphier / mazegen.py
Created October 27, 2015 17:38
Maze generator script for python
#original script by Nikolaus Gradwohl 2012-05-21T05:08:35+02:00
#http://www.local-guru.net/blog/2012/5/21/blender-labyrinth-generator
from random import shuffle
from array import *
import bpy
def GetName( cnt ):
if (cnt < 100 and cnt > 9):
return 'm0' + str(cnt)
@Naphier
Naphier / NGDebug.cs
Created October 11, 2015 17:04
Replacement for Unity's debug so we can just shut it off for production
using UnityEngine;
/// <summary>
/// Replacement for Unity's debug so we can just shut it off for production
/// </summary>
public class NGDebug
{
private enum WarningLevel
{ all, warning, error, none }
using UnityEngine;
// Displays lines for the Local Axis of a game object evenwhen the object is not selected.
public class ShowLocalAxis : MonoBehaviour
{
// This is used by the CustomTransformComponent class
// and the custom inspector for this class so that we can tag the script component
// for deletion at the proper time. We're hiding it in the inspector since it shouldn't
// be modified by the user, but needs to be publically accessible by other classes.
[HideInInspector]
using UnityEngine;
using UnityEditor;
// This custom Inspector just shows the default inspector and
// then, at the correct time, destroys the component if it has
// been flagged for destruction.
[CustomEditor(typeof(ShowLocalAxis))]
public class ShowLocalAxisInspector : Editor
{
public override void OnInspectorGUI()