Skip to content

Instantly share code, notes, and snippets.

View robertwahler's full-sized avatar

Robert Wahler robertwahler

View GitHub Profile
@robertwahler
robertwahler / button_sample.lua
Created December 28, 2012 17:23
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
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 December 13, 2015 21:48
Thor tasks to run MOAI binaries independent of OS.
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")
#!/bin/sh
haxelib run openfl $@
using System;
using FullSerializer;
namespace SDD.Serializers {
public static class JsonSerializer {
/// <summary>
/// Static Serializer Instance
/// </summary>
@robertwahler
robertwahler / Shortcuts.cs
Last active August 10, 2018 23:06
Unity Shortcuts via Reflection
using UnityEditor;
using UnityEngine;
using UnityTest;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace SDD.Editor {
/// <summary>
@robertwahler
robertwahler / WaitForExample.cs
Created October 20, 2015 13:11
Avoid Unity garbage collection when coroutines wait
// 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 / DynamicLayoutGroup.cs
Last active July 16, 2024 10:01
Unity 3D layout group switches orientation automatically between landscape and portrait layouts so it either acts like a VerticalLayoutGroup or a HorizontalLayoutGroup.
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System.Collections;
using System.Collections.Generic;
namespace SDD.UI {
/// <summary>
/// Layout group switches orientation automatically between landscape and
@robertwahler
robertwahler / JsonSerializerBinderTest.cs
Last active June 27, 2016 18:47
Testing Newtonsoft.Json Binder
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 August 1, 2016 21:38
Empty folders, #git, & #unity3d don't mix. Git doesn't track empty folders, why does @Unity3D?
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 / FileIO.jslib
Created April 12, 2018 13:08
UnityEngine.PlayerPrefs wrapper for WebGL LocalStorage
var FileIO = {
SaveToLocalStorage : function(key, data) {
localStorage.setItem(Pointer_stringify(key), Pointer_stringify(data));
},
LoadFromLocalStorage : function(key) {
var returnStr = localStorage.getItem(Pointer_stringify(key));
var bufferSize = lengthBytesUTF8(returnStr) + 1;
var buffer = _malloc(bufferSize);