Skip to content

Instantly share code, notes, and snippets.

View worthingtonjg's full-sized avatar

Jon Worthington worthingtonjg

View GitHub Profile
@worthingtonjg
worthingtonjg / unity3dlinks.md
Last active August 23, 2017 02:32
Unity3d Links
@worthingtonjg
worthingtonjg / unity.snippet
Last active September 17, 2016 18:18
Unity-Snippets
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>DontDestroyOnLoad</Title>
<Description>Keep an object alive across scenes</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
<Shortcut>DontDestroyOnLoad</Shortcut>
using UnityEngine;
using System.Collections;
public enum enColorchannels
{
all =0,
red =1,
blue =2,
green =3
}
@worthingtonjg
worthingtonjg / jekyll.txt
Last active October 7, 2018 05:57
Jekyll commands
jekyll new <sitename>
bundle exec jekyll serve
jekyll serve
jekyll serve --draft
_config.yml
Gemfile
Themes:
https://rubygems.org/
@worthingtonjg
worthingtonjg / BasicFly.cs
Last active December 9, 2018 06:19
Add this script to any Unity GameObject or Camera to enable it to fly around the scene. Will fly in the direction the camera is facing.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Camera))]
public class BasicFly : MonoBehaviour {
public float rotationSpeed = 100.0f;
public float moveSpeed = 100f;
public float viewRange = 45f;
@worthingtonjg
worthingtonjg / SimpleFly.cs
Last active December 9, 2018 06:18
More complex than BasicFly.cs, cannot be placed directly on a camera, but instead requires a camera as a child. This script still moves using Transform.Translate (so will fly through colliders). Uses <space> and <shift> to rise or fall, and flies flat regardless of the vertical camera pitch. Designed to work similar to the Minecraft camera.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SimpleFly : MonoBehaviour {
public float rotationSpeed = 100.0f;
public float moveSpeed = 100f;
public float viewRange = 45f;
private Transform cameraTransform;
@worthingtonjg
worthingtonjg / BaseState.cs
Created December 27, 2018 05:51
Base class for state in simple state machine
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BaseState {
public virtual void InitState () {
}
@worthingtonjg
worthingtonjg / StateController.cs
Created December 27, 2018 05:52
Controller for simple state machine
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StateController<T> : MonoBehaviour where T : BaseState {
protected T currentState;
public void ChangeState(T newState) {
#if STATEMACHINE_DEBUG
@worthingtonjg
worthingtonjg / SceneLoader.cs
Created January 24, 2019 03:41
Combine multiple scenes into a single scene.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.Events;
using System.Threading;
using System;
public class SceneLoader : MonoBehaviour
{
https://www.youtube.com/watch?v=Tef42KUQMOk