I hereby claim:
- I am karlgluck on github.
- I am karlgluck (https://keybase.io/karlgluck) on keybase.
- I have a public key whose fingerprint is 6797 F0BC 1431 E8CB 5E34 D924 B4F7 4EB0 FF8B 9035
To claim this, I am signing this object:
// this lets you write bits to a buffer and scan them back: | |
// | |
// char buffer[3]; | |
// bitfield writer(buffer); | |
// writer.write(2,6); // write "2" as a 6-bit uint | |
// writer.write(9,4); // write "9" as a 4-bit uint | |
// writer.write(0,1); // etc | |
// writer.write(1,2); | |
// size_t bytes = writer.bytes(buffer); // bytes == 2 |
I hereby claim:
To claim this, I am signing this object:
import requests, json | |
import os | |
import re | |
import time | |
import datetime | |
data_dir = os.path.dirname(os.path.realpath(__file__)) + '/data' | |
api_url = 'https://api.twitch.tv/kraken/games/top?limit=100' |
I'm working on some side projects and have been toying with ideas for more efficient ways to write games in Unity with C#. One of the major hangups for some of my larger side projects is that once it reaches sufficient complexity, it's hard to tell exactly what state the app is in. Even the simple wallet app I built has this issue. I've come up with the beginnings of a solution so I wanted to write it down before it gets lost.
The key problem is that you want your program to respond to inputs that require waiting for a response from something (a webserver, a user, etc). There are a number of options in Unity with C#.
These first 4 options are variations on a theme of control "elsewhere" in the program letting your code know that something has happened:
OnMouseMove
on a class and that function gets called whenever the mouse movesfunction doGet(request) | |
{ | |
var lock = LockService.getPublicLock(); | |
lock.waitLock(15000); | |
var ss = SpreadsheetApp.openById(request.parameter.id); | |
var sheet = ss.getSheetByName('Sheet1'); | |
var obj; | |
var dataRange = sheet.getRange(1, 1, sheet.getLastRow(), sheet.getLastColumn()); | |
var dataValues = dataRange.getValues(); | |
if (request.parameter.k && request.parameter.v) { |
using System; | |
using System.Collections; | |
using System.Reflection; | |
using UnityEngine.Scripting; | |
// [Bind] is used to annotate a static field or property of type Func or Action. It causes | |
// the value of that member to be mapped to a function somewhere else in the program with the | |
// same name as that field. The target function can be a static function or an instance | |
// function whose class has a static property/field of its own type named "Singleton". | |
// |
public static bool IsPointInside (Vector2 point, Vector2[] polygonBoundary) | |
{ | |
int i = 0, j = 1; | |
int retval = 0; | |
while (j < polygonBoundary.Length) | |
{ | |
var pointI = polygonBoundary[i]; | |
var pointJ = polygonBoundary[j]; | |
int side = (pointJ.x - pointI.x) * (point.y - pointI.y) - (point.x - pointI.x) * (pointJ.y - pointI.y); | |
int upward = ((side > 0) & (pointI.y <= point.y) & (pointJ.y > point.y)) ? +1 : 0; |
Install Gvim
Right-click the C:\Program Files (x86)\Vim
folder and change its Security permissions to allow full control & editing
-> You shouldn't have to give admin permissions to do anything else in this guide
Install pathogen.vim
Clone OmniSharp-vim to C:\Program Files (x86)\Vim\vimfiles\bundle\omnisharp-vim
private static Vector3 ViewportToWorldPointUnity (Vector3 point, float fieldOfView, float aspect, Vector3 from, Vector3 to, Vector3 up) | |
{ | |
// The zNear / zFar magic numbers are what Unity's viewport always uses regardless of camera settings | |
var matP = Matrix4x4.Perspective (fieldOfView, aspect, 0.6f /* zNear */, 1000f /* zFar */); | |
// For some reason we have to reverse these coordinates | |
from = -from; | |
to = -to; |
public class ECSEntity | |
{ | |
public ArrayList Components; | |
public static ECSEntity Acquire () | |
{ | |
throw new System.NotImplementedException(); | |
ECSEntity retval = null; | |
return retval; | |
} |