Skip to content

Instantly share code, notes, and snippets.

graph map {
node [fillcolor="#444444", fontcolor="white", style=filled, shape=box]
edge [color="#666666"]
room0 [label="room0"]
room1 [label="room1" fillcolor="#44CC44"]
room2 [label="room2"]
room0 -- room1
room1 -- room2
@rje
rje / enumfunc.cs
Created October 21, 2014 21:16
Generic function to convert a string into an enum type
public T ReadEnum<T>(string tok)
{
if(typeof(T).IsEnum == false)
{
Debug.LogWarning("Generic type " + typeof(T).Name + " passed to ReadEnum<T> is not an enum type, returning default value");
return default(T);
}
T toReturn = default(T);
try
@rje
rje / Catalog.cs
Created October 24, 2014 22:25
generic 'catalog' singleton
public interface ICatalogEntry
{
string GetName();
}
public class Catalog<T> where T : ICatalogEntry
{
static Catalog<T> _instance = new Catalog<T>();
@rje
rje / gist:17d2669f8e36131fd395
Last active August 29, 2015 14:09
UE4 networking bug: Can't connect windows and mac builds together
I'm working on a game for #7dfps and I'm at the point where I have basic networking functionality up and running (host game, join game, transition to arena when players have joined, etc). Everything goes great if I have a mac build connect to a mac build, or a windows build connect to a windows build. But I get errors every time I try to connect a mac build to a windows build. I tried windows hosting, mac client & mac hosting, windows client.
Windows is version 8.1 64 bit, running a 64 bit development build
Mac is version 10.10, running a 64 bit development build
Digging into the logs on the mac when it was the client, I found the following information. I verified that I'm seeing similar errors on windows when it acts as the client. Any idea what could cause this?
The client is attempting to join the game with the command "open <ip address>" being executed as a console command in blueprints. Previously the host machine would have started listening by opening a map (via a console command in blueprint) with
@rje
rje / gist:9d39a63a2be285846060
Created December 4, 2014 23:17
double parse test
double val;
var succeeded = double.TryParse("1.05", out val);
Debug.Log("Did parse succeed? " + succeeded + " parsed value is: " + val);
@rje
rje / tru_checker.js
Last active August 29, 2015 14:11
lucario check
var cheerio = require('cheerio');
var request = require('request');
var CronJob = require('cron').CronJob;
var url = 'http://www.toysrus.com/product/index.jsp?productId=54369136&prodFindSrc=search&cp=';
function showResult(text) {
var proc = require('child_process');
if(process.platform === 'darwin')
{
@rje
rje / SelectPrefabsOfType.cs
Last active November 29, 2024 02:58
Small unity utility to find all prefab objects that have a given component on them
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System;
using System.Reflection;
public class SelectPrefabsOfType : EditorWindow {
[MenuItem("Window/Prefab Finder")]
@rje
rje / list_examples.cs
Created January 30, 2015 17:37
Things I do a lot with lists
// Things I do a lot with lists:
// Creation
var list = new List<GameObject>();
// Lists resize dynamically as you add content, but if
// you roughly know how many elements you plan on having
// you can specify a capacity on creation
list = new List<GameObject>(200);
public class ConsoleCommandRouter : MonoBehaviour {
void Start () {
var repo = ConsoleCommandsRepository.Instance;
repo.RegisterCommand("toggle_boolean", ToggleBoolean);
}
public string ToggleBoolean(params string[] args) {
// args is an array of strings representing all the words after "toggle_boolean" on the console line you typed
// here is where you'd want to find whatever GameObject or class you'd want to modify and do your thing
// might look something like:
public AnimationCurve _transitionCurve;
public IEnumerator MyCustomTransition(Vector3 orig, Vector3 dest, float duration)
{
var time = 0.0f;
var difference = dest - orig;
while (time <= duration)
{
var percentage = Mathf.Clamp01(time / duration);
var curveValue = _transitionCurve.Evaluate(percentage);
var pos = orig + curveValue * difference;