Skip to content

Instantly share code, notes, and snippets.

View cubed2d's full-sized avatar

Louise James cubed2d

  • Generic Evil Business
  • London
View GitHub Profile
@cubed2d
cubed2d / NetworkBehaviour.cs
Created February 22, 2014 17:21
NetworkBehaviour
using UnityEngine;
using System.Collections;
using System;
public abstract class NetworkBehaviour<T> : MonoBehaviour where T : INetworkPacket, new()
{
public T Packet = new T();
public T LastPacket = new T();
public NetworkingManager Manager;
public bool IsEchoEnabled = true;
public class NetworkingManager : MonoBehaviour
{
public static NetworkingManager Instance;
public bool IsServer;
public string IpAddress = "127.0.0.1";
public int Port = 8888;
public Transform PlayerRootPrefab;
public List<NetworkPlayerRecord> Players = new List<NetworkPlayerRecord>();
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Diagnostics;
public class NetworkBuilder
{
[MenuItem("Networking/Build and Run Server %#x")]
public static void BuildAndRunServer()
{
public WaitForFixedUpdate Wait = new WaitForFixedUpdate();
public IEnumerator PhysicsCoroutine()
{
while (true)
{
yield return Wait;
}
}
@cubed2d
cubed2d / gist:7985224
Created December 16, 2013 10:47
game unit
#==============================================================================
# ** Game_Unit
#------------------------------------------------------------------------------
# This class handles units. It's used as a superclass of the Game_Party and
# and Game_Troop classes.
#==============================================================================
class Game_Unit
#--------------------------------------------------------------------------
# * Public Instance Variables
@cubed2d
cubed2d / gist:5217832
Last active December 15, 2015 06:39
Example of how i draw the awesome Array/List inspectors in the swindle
public override void OnInspectorGUI2()
{
// First off, cache a copy of target cast to its type, makes like easier. EXAMPLE
AmbientLight light = target as AmbientLight;
// This is to top area of the inspector GUI. draw controls here for making chages to parts of the target object that arnt part of the array.
light.timeOfDay = EditorGUILayout.Slider("Time of Day", light.timeOfDay, 0, 24);
// leave some space to split the main settings from the array
EditorGUILayout.Space();
@cubed2d
cubed2d / StringExtentions.cs
Created March 13, 2013 13:27
Super simple swear word filter based off googles bad word list.
public static class StringExtentions
{
//bad word list specal thanks to google! (https://gist.github.com/jamiew/1112488)
private static string[] badwords = new[] { "4r5e", "5h1t", "5hit", "a55", "anal", "anus", "ar5e", "arrse", "arse", "ass", "ass-fucker", "asses", "assfucker", "assfukka", "asshole", "assholes", "asswhole", "a_s_s", "b!tch", "b00bs", "b17ch", "b1tch", "ballbag", "balls", "ballsack", "bastard", "beastial", "beastiality", "bellend", "bestial", "bestiality", "bi+ch", "biatch", "bitch", "bitcher", "bitchers", "bitches", "bitchin", "bitching", "bloody", "blow job", "blowjob", "blowjobs", "boiolas", "bollock", "bollok", "boner", "boob", "boobs", "booobs", "boooobs", "booooobs", "booooooobs", "breasts", "buceta", "bugger", "bum", "bunny fucker", "butt", "butthole", "buttmuch", "buttplug", "c0ck", "c0cksucker", "carpet muncher", "cawk", "chink", "cipa", "cl1t", "clit", "clitoris", "clits", "cnut", "cock", "cock-sucker", "cockface", "cockhead", "cockmunch", "cockmuncher", "cocks", "cocksuck",
// attach this to a camera. It sets the sort mode so 2D object are rendered correctly with a perspective camera.
public class CameraSortModeSetter : MonoBehaviour
{
void Update()
{
if (camera != null && camera.transparencySortMode != TransparencySortMode.Orthographic)
camera.transparencySortMode = TransparencySortMode.Orthographic;
}
}
@cubed2d
cubed2d / gist:4073355
Created November 14, 2012 17:05
How to draw a toolbar
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
GUILayout.Label("Toolbar Title");
GUILayout.FlexibleSpace();
if (GUILayout.Button("A", EditorStyles.toolbarButton))
{
// does something
}
if (GUILayout.Button("B", EditorStyles.toolbarButton))
{
// does something
@cubed2d
cubed2d / gist:4073256
Created November 14, 2012 16:50
Transform2DInspector.cs
[CustomEditor(typeof(Transform))]
public class Transform2DInspector : Editor
{
public override void OnInspectorGUI()
{
// Grab the target transform
Transform transform = (Transform)target;
tk2dBaseSprite sprite = transform.gameObject.GetComponent<tk2dBaseSprite>();
if (sprite != null)