Skip to content

Instantly share code, notes, and snippets.

View Naphier's full-sized avatar
🐲

Sean Mann Naphier

🐲
View GitHub Profile
@Naphier
Naphier / OutputStrategy.cs
Created December 30, 2015 17:51
Strategy Pattern Example - String Output - EncryptedOutput
public class EncryptedOutput : IOutputStrategy
{
public string Output(string input)
{
char[] array = input.ToCharArray();
for (int i = 0; i < array.Length; i++)
{
int number = (int)array[i];
if (number >= 'a' && number <= 'z')
@Naphier
Naphier / OutputStrategy.cs
Created December 30, 2015 18:00
Strategy Pattern Example - String Output - OutputContext
public class OutputContext
{
IOutputStrategy outputStrategy;
public OutputContext(IOutputStrategy outputStrategy)
{
this.outputStrategy = outputStrategy;
}
public string GetOutput(string input)
{
@Naphier
Naphier / OutputStrategyController.cs
Created December 30, 2015 18:14
Strategy Pattern Example - String Output
public class OutputStrategyController : MonoBehaviour
{
public string input = "This is some arbitrary input string";
void Start()
{
OutputContext context = new OutputContext(new CSVOutput(' '));
Debug.Log("This is the CSV output:\n" + context.GetOutput(input));
//Easily change the context!
@Naphier
Naphier / ComponentCache.cs
Last active February 1, 2016 09:36
CacheBehaviour alternative
using UnityEngine;
using System.Collections.Generic;
public class ComponentCache
{
public enum LogMessageLevel { all, error, none}
LogMessageLevel logMessageLevel = LogMessageLevel.error;
private GameObject _gameObject;
private List<Component> _components = new List<Component>();
@Naphier
Naphier / InputDetector.cs
Created March 19, 2016 04:32
A little helper that to figure out your inputs.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
public class InputDetector : MonoBehaviour
{
public enum TestType { joystickButtons, keys, axis, mouse, touch }
public TestType testType = TestType.joystickButtons;
public bool logMessages = true;
@Naphier
Naphier / NaplandCamera.cs
Created April 28, 2016 19:18
Gets screen bounds based on camera.
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(Camera))]
public class NaplandCamera : MonoBehaviour {
#pragma warning disable 0414
public static float minX;
public static float maxX;
@Naphier
Naphier / Vector3Ext.cs
Created May 4, 2016 16:42
Vector3 Multilerp (multiple lerps) for handline waypoints.
using System;
using UnityEngine;
namespace NG
{
public static class Vector3Ext
{
#region Multilerp
// This is not very optimized. There are at least n + 1 and at most 2n Vector3.Distance
// calls (where n is the number of waypoints).
LICENSE SYSTEM [2016818 0:55:25] No start/stop license dates set
LICENSE SYSTEM [2016818 0:55:25] Next license update check is after 2016-08-07T20:46:52
Built from '5.3/patch-release' branch; Version is '5.3.4p5 (83b1f50dd5b8) revision 8630773'; Using compiler version '160040219'
OS: 'Windows 10 (10.0.0) 64bit' Language: 'en' Physical Memory: 16284 MB
BatchMode: 0, IsHumanControllingUs: 1, StartBugReporterOnCrash: 1, Is64bit: 1, IsPro: 0
Initialize mono
Mono path[0] = 'E:/Unity_5.3.4p5/Editor/Data/Managed'
@Naphier
Naphier / Editor\MakeSpriteTexture.cs
Created November 21, 2016 21:20
Simple editor script that will create a 4x4 texture of the specified color. Useful for prototyping with sprites.
using UnityEngine;
using UnityEditor;
public class MakeSpriteTexture : EditorWindow
{
[MenuItem("Assets/Create Sprite")]
static void Init()
{
MakeSpriteTexture window = GetWindow<MakeSpriteTexture>("Create Sprite");
@Naphier
Naphier / UGuiTextToTextMeshPro.cs
Created January 4, 2017 15:23
Unity3D Editor Tool to convert Unity GUI Text objects to Text Mesh Pro Text Objects
using UnityEngine;
using UnityEditor;
using UnityEngine.UI;
using TMPro;
using TMPro.EditorUtilities;
public class UGuiTextToTextMeshPro : Editor
{
[MenuItem("GameObject/UI/Convert To Text Mesh Pro", false, 4000)]
static void DoIt()