Skip to content

Instantly share code, notes, and snippets.

Avatar

Robert Wahler robertwahler

View GitHub Profile
View JsonSerializer.cs
using System;
using FullSerializer;
namespace SDD.Serializers {
public static class JsonSerializer {
/// <summary>
/// Static Serializer Instance
/// </summary>
@robertwahler
robertwahler / WaitForExample.cs
Created Oct 20, 2015
Avoid Unity garbage collection when coroutines wait
View WaitForExample.cs
// Avoid GC when coroutines wait, instantiate outside of loop
WaitForSeconds shortWait = new WaitForSeconds(1.0f);
private IEnumerator Run() {
while (true) {
// do stuff here
yield return shortWait;
}
}
@robertwahler
robertwahler / button_sample.lua
Created Dec 28, 2012
Modified hannappe sample showing layout resize issue. Run this sample and use the mouse to change the window size. It works when making the window bigger. When you make the window smaller, the buttons don't change alignment. hanappe/projects/hanappe-samples/src/samples/gui/button_sample.lua
View button_sample.lua
module(..., package.seeall)
function onCreate(params)
view = View {
scene = scene,
layout = {
VBoxLayout {
align = {"center", "center"},
padding = {10, 10, 10, 10},
}
@robertwahler
robertwahler / basic_moai_helper.rb
Last active Dec 13, 2015
Thor tasks to run MOAI binaries independent of OS.
View basic_moai_helper.rb
require 'pathname'
require 'rbconfig'
require 'fileutils'
module BasicMoai
ROOT_FOLDER = File.expand_path(File.join(File.dirname(__FILE__), ".."))
SRC_FOLDER = File.join(ROOT_FOLDER, "src")
VENDOR_FOLDER = File.join(ROOT_FOLDER, "vendor")
TMP_FOLDER = File.join(ROOT_FOLDER, "tmp")
View openfl
#!/bin/sh
haxelib run openfl $@
@robertwahler
robertwahler / JsonSerializerBinderTest.cs
Last active Jun 27, 2016
Testing Newtonsoft.Json Binder
View JsonSerializerBinderTest.cs
using UnityEngine;
using System;
using System.Reflection;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Runtime.Serialization.Formatters;
using System.Linq;
using NUnit.Framework;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
@robertwahler
robertwahler / code.rb
Last active Aug 1, 2016
Empty folders, #git, & #unity3d don't mix. Git doesn't track empty folders, why does @Unity3D?
View code.rb
module BasicUnity
class Code < Thor
namespace :code
include Thor::Actions
desc "prune", "Remove empty folders and Unity meta files that point to empty folders"
method_option "dry-run", :type => :boolean, :desc => "Show what will happen but don't 'rmdir' or 'rm'"
def prune(folder=nil)
# bash version, requires GNU find
@robertwahler
robertwahler / ScreenCapture.cs
Created May 3, 2018
Unity snippet for supersizing in-engine screenshots
View ScreenCapture.cs
// Take up to 10 screenshots per session, then start overwriting
private IEnumerator Capture(string path=null, string filename=null) {
Log.Debug(string.Format("ScreenCapture.Capture(path: {0}, filename: {1}) Settings.DataPath={0}", path, filename, Settings.DataPath));
screenShotCount += 1;
if (screenShotCount > 10) {
screenShotCount = 1;
}
if (filename == null) {
@robertwahler
robertwahler / Settings.cs
Created May 8, 2018
Unity DataPath property w/ hard coded macOS path
View Settings.cs
/// <summary>
/// The root data folder. Used by the entire application to read and write
/// data, not just used by the Settings class. This is an absolute path.
/// </summary>
#if UNITY_EDITOR
// Each product has its own folder in tmp when running in the editor.
// This allows audio and other debug settings to be separate from
// standalone builds on the same development machine.
// NOTE: The hard-coded forward slash should work on Windows, Linux, and OSX.
public static string DataPath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "tmp/settings/" + Application.productName);
@robertwahler
robertwahler / Shortcuts.cs
Last active Aug 10, 2018
Unity Shortcuts via Reflection
View Shortcuts.cs
using UnityEditor;
using UnityEngine;
using UnityTest;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace SDD.Editor {
/// <summary>