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
public WaitForFixedUpdate Wait = new WaitForFixedUpdate();
public IEnumerator PhysicsCoroutine()
{
while (true)
{
yield return Wait;
}
}
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 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>();
@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;
using UnityEngine;
using System.Collections;
public class APIExamples : MonoBehaviour
{
public int randomColorCount = 5;
public Color[] RandomBrightColors;
public Color[] RandomPastelColors;
public Color[] RandomDarkColors;
using System;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityColor32 = UnityEngine.Color32;
[Serializable]
[StructLayout(LayoutKind.Explicit)] // Tell .net that we know exactly where we want these values
public struct Color32
{
[FieldOffset(0)]
@cubed2d
cubed2d / Degub.cs
Created October 16, 2014 13:07
fix for error CS0103: aka Degub
public static class Degub
{
public static void Log(object message)
{
Debug.Log(message);
}
public static void Log(object message, Object context)
{
Debug.Log(message, context);
public Random random; <- put this in one of your class files (Usually Xna has a Game class? probably that one
random = new Random(); <-- In the same file put this somewhere. Xna games tend to have a LoadContent or a Initialize method? that would be a good place. This creates and instance of the Random class. Random is an object that has lots of methods for giving you differnt types of random numbers, like the name suggests! :)
var item = myList[random.Next(myList.count)]; <- WHen you want to get the random item. the Next method on Random makes it generate the next random number. Passing in the length/count of the items in your list makes it generate a number thats between 0 and that number.
using UnityEngine;
using UnityEditor;
using System.Collections;
public class MakeMMOButton : MonoBehaviour {
[MenuItem("Edit/Make MMO", false, 5)]
static void OnMakeMMOButton()
{
throw new System.NotImplementedException();
In PlayerScript:
// Sprite direction
if (xInput > 0) {
transform.rotation = Quaternion.Euler (0, 0, 0);
} else if (xInput < 0) {
transform.rotation = Quaternion.Euler (0, 180, 0);
}
// Aiming