Skip to content

Instantly share code, notes, and snippets.

View drawcode's full-sized avatar
😎
Shipping product

Ryan Christensen drawcode

😎
Shipping product
View GitHub Profile
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
public class ByteArray {
private MemoryStream stream;
private BinaryWriter writer;
public ByteArray() {
@drawcode
drawcode / unity_ios_verificationsignature.md
Created January 14, 2024 18:50 — forked from BastianBlokland/unity_ios_verificationsignature.md
Way to get the game-center verification signature with Unity.

Even tho Unity has implemented a game-center api (Social api) it doesn't have a way to generate a verification signature, which you need to use game-center as a authentication method.

Luckily the objective-c code required is pretty straight forward. (Apple documentation: generateIdentityVerificationSignature)

#import <Foundation/Foundation.h>
#import <GameKit/GameKit.h>

typedef void (*IdentityVerificationSignatureCallback)(const char * publicKeyUrl, const char * signature, int signatureLength, const char * salt, int saltLength, const uint64_t timestamp, const char * error);

This version completely strips the page.

javascript:(function(){var n=document.getElementsByClassName('Box-body')[0].cloneNode(true);document.body.children[0].remove();document.body.appendChild(node);node.style.borderBottom = 'none';})();
@drawcode
drawcode / AESGCM.cs
Created January 20, 2014 18:58 — forked from jbtule/AESGCM.cs
/*
* This work (Modern Encryption of a String C#, by James Tuley),
* identified by James Tuley, is free of known copyright restrictions.
* https://gist.github.com/4336842
* http://creativecommons.org/publicdomain/mark/1.0/
*/
using System;
using System.IO;
using System.Text;
@drawcode
drawcode / GameObjectExtensions.cs
Created December 10, 2012 22:01
Unity Extensions C#
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
using Engine.Utility;
public static class GameObjectExtensions {
public static void SetLayerRecursively(this GameObject inst, int layer) {
@drawcode
drawcode / WebWindow.cs
Created January 22, 2013 18:11
Unity WebWindow (browser within unity editor window, helpful for tools that require a web view or more beyond basic controls).
using UnityEngine;
using UnityEditor;
using System;
using System.Reflection;
public class WebWindow : EditorWindow {
static Rect windowRect = new Rect(100,100,800,600);
static BindingFlags fullBinding = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static;
static StringComparison ignoreCase = StringComparison.CurrentCultureIgnoreCase;
@drawcode
drawcode / oracle_check_column_exists.sql
Last active March 23, 2023 08:18
Check if column exists on table in PGSQL
select table_name from user_tab_columns
where table_name = myTable and column_name = myColumn;
@drawcode
drawcode / .gpu-instancing.md
Last active February 14, 2023 16:19
Unity GPU Instancing

https://docs.unity3d.com/Manual/GPUInstancing.html

GPU Instancing (Unity)

Introduction

Use GPU Instancing to draw (or render) multiple copies of the same Mesh at once, using a small number of draw calls. It is useful for drawing objects such as buildings, trees and grass, or other things that appear repeatedly in a Scene .

GPU Instancing only renders identical Meshes with each draw call, but each instance can have different parameters (for example, color or scale) to add variation and reduce the appearance of repetition.

@drawcode
drawcode / unity-vector3-refract.cs
Created January 6, 2019 07:14
unity-vector3-refract.cs
/**
* returns:
* normalized Vector3 refracted by passing from one medium to another in a realistic manner according to Snell's Law
*
* parameters:
* RI1 - the refractive index of the first medium
* RI2 - the refractive index of the second medium
* surfNorm - the normal of the interface between the two mediums (for example the normal returned by a raycast)
* incident - the incoming Vector3 to be refracted
*
@drawcode
drawcode / recover-deleted-branch.sh
Created October 11, 2022 02:32 — forked from umayr/recover-deleted-branch.sh
How to recover a deleted branch
## Pre-requisite: You have to know your last commit message from your deleted branch.
git reflog
# Search for message in the list
# a901eda HEAD@{18}: commit: <last commit message>
# Now you have two options, either checkout revision or HEAD
git checkout a901eda
# Or
git checkout HEAD@{18}