Skip to content

Instantly share code, notes, and snippets.

be gentle.

Toru sassembla

be gentle.
Block or report user

Report or block sassembla

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View EditorScreenshotScript
public static void Menu()
var tex = ScreenCapture.CaptureScreenshotAsTexture();
var jpgBytes = tex.EncodeToJPG(10);// 90KB
using (var sw = new StreamWriter("a.jpg"))
sw.BaseStream.Write(jpgBytes, 0, jpgBytes.Length);
sassembla / StopAfterCompileProcess.cs
Created Aug 28, 2018
View StopAfterCompileProcess.cs
using UnityEditor;
using UnityEngine;
public class StopAfterCompileProcess
public static void StopAfterCompile()
if (EditorApplication.isPlaying)
View uGUIがレイアウトする「想定」の文字の改行や位置情報をどう取得するか
// Text textComponent みたいなものに対して
// TextGenerator generator = new TextGenerator(); みたいなのをグローバルで取得しておいて使い回すことができる
// invalidate first.
// set content to prefab.
var defaultText = textComponent.text;
textComponent.text = text;
View TMProがレイアウトする「想定」の文字の改行や位置情報をどう取得するか
// TMProのコンポーネント TMPro.TextMeshProUGUI textComponentというのがあったとして
textComponent.text = text;
// textComponentに対してwidthをセットする必要がある。高さは無限設定でOK
textComponent.rectTransform.sizeDelta = new Vector2(viewWidth, float.PositiveInfinity);
// このメソッドは、コンポーネントがgameobjectにアタッチされて、かつgameobjectがcanvasに乗っている場合のみ動作する。
var textInfos = textComponent.GetTextInfo(text);
#import "UnityAppController.h"
@interface OverrideAppDelegate : UnityAppController
sassembla / ResourcesController.cs
Created Apr 6, 2018
ResourcesController for Autoya.
View ResourcesController.cs
using System;
using System.Collections;
using AutoyaFramework;
using UnityEngine;
public class ResourcesController
public static void LoadAsset<T>(string assetPath, Action<string, T> succeeded, Action<string, int, string, object> failed) where T : UnityEngine.Object
var resRequest = Resources.LoadAsync(assetPath);
sassembla / SingletonHolder.cs
Last active Jun 13, 2019
automated singleton holder for Unity. auto-initialize on Player boot time and well isolated.
View SingletonHolder.cs
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class SingletonHolder : MonoBehaviour {
private List<Base> instances = new List<Base>();
private static SingletonHolder holderInstance;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] private static void NewSingleton () {
sassembla / XrossPeerUtility.cs
Created Apr 7, 2016
View XrossPeerUtility.cs
using System;
using System.IO;
using System.Collections.Generic;
using System.Globalization;
namespace XrossPeerUtility {
public class XrossPeer {
static string logPath = string.Empty;
private static Action<string> logAction;
View redis_connection_server.lua
-- get identity of game from url. e.g. http://somewhere/game_key -> game_key
local identity = string.gsub (ngx.var.uri, "/", "")
-- generate pub-sub key from url.
IDENTIFIER_CENTRAL = identity .. "_pub"
IDENTIFIER_CLIENT = identity .. "_sub"
You can’t perform that action at this time.