This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function RandomNext(array) { | |
return array[Math.random() * array.length | 0]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Unity" to activate -- needs to be in front | |
tell application "System Events" to tell application process "Unity" | |
try | |
get properties of window 1 | |
set size of window 1 to {1280, 720} | |
on error errmess | |
log errmess | |
-- no window open | |
end try | |
end tell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Scene = require('Scene'); | |
const Reactive = require('Reactive'); | |
const Textures = require('Textures'); | |
const output = alphaMask(Textures.get('colorTexture'), Textures.get('alphaTexture')) | |
const plane1 = Scene.root.find('plane1'); | |
plane1.material.setTexture(output, { textureSlotName: 'DIFFUSE' }) | |
function alphaMask(diffuse, alpha, invert) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
const Scene = require('Scene'); | |
const Diagnostics = require('Diagnostics'); | |
const plane0 = Scene.root.find('plane0'); | |
plane0.transform.x = 1; | |
Diagnostics.log(plane0.transform.x.pinLastValue()); // 0 | |
onSetSignal(plane0.transform.x, Diagnostics.log); // 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://www.timegamers.com/threads/friday-update-detecting-the-konami-code-with-unirx.1723/ | |
using UnityEngine; | |
using UniRx; | |
using System.Linq; | |
using System; | |
public class KonamiCode : MonoBehaviour | |
{ | |
void Start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using System.Runtime.InteropServices; | |
using UnityEngine; | |
public class WindowsTouchKeyboard | |
{ | |
[DllImport("user32")] static extern IntPtr FindWindow(String sClassName, String sAppName); | |
[DllImport("user32")] static extern bool PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const FFMPEG_PATH = 'usr/local/bin/ffmpeg'; | |
//–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– | |
const app = Application.currentApplication() | |
app.includeStandardAdditions = true | |
function openDocuments(droppedItems) { | |
const changeExtension = (file, newExtension) => file.substr(0, file.lastIndexOf(".")) + `.${newExtension}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Locale = require('Locale'); | |
const Diagnostics = require('Diagnostics'); | |
(async function () { | |
const [language, locale, region] = await Promise.all([ | |
pinInitialValueAsync(Locale.language), | |
pinInitialValueAsync(Locale.locale), | |
pinInitialValueAsync(Locale.region), | |
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gradually changes a value towards a desired goal over time - implemented from Unity C# | |
*/ | |
public func smoothDamp(current c: CGFloat, target t: CGFloat, currentVelocity: inout CGFloat, smoothTime time: CGFloat, maxSpeed: CGFloat = CGFloat.infinity, deltaTime: CGFloat) -> CGFloat { | |
let smoothTime = max(0.0001, time) | |
let num = 2 / smoothTime | |
let num2 = num * deltaTime | |
let num3 = 1 / (1 + num2 + 0.48 * num2 * num2 + 0.235 * num2 * num2 * num2) | |
var num4 = c - t | |
let num5 = t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static bool IsQuestionMark(Texture2D texture) | |
{ | |
if (texture.width == 8 && texture.height == 8) | |
{ | |
using (var md5Provider = new System.Security.Cryptography.MD5CryptoServiceProvider()) | |
{ | |
var raw = texture.GetRawTextureData(); | |
var md5 = md5Provider.ComputeHash(raw); | |
return System.BitConverter.ToString(md5) == "07-6B-BF-9B-9D-80-03-1E-80-AD-2C-A7-DB-D1-AD-B5"; | |
} |