Skip to content

Instantly share code, notes, and snippets.

@snaka
snaka / file0.txt
Created July 30, 2014 13:02
実行時にシェーダを差し替える ref: http://qiita.com/snaka/items/f7065604ce7306282821
// change shader
var defaultShader = Shader.Find ("Sprites/Default");
var renderers = ((GameObject)instance).GetComponentsInChildren<SpriteRenderer>();
foreach (var r in renderers) {
r.material.shader = defaultShader;
}
@snaka
snaka / SourceFileEncodingChecker.cs
Created July 30, 2014 11:15
ソースコード修正時にファイルエンコーディングがBOM付きUTF-8かどうかをチェックする ref: http://qiita.com/snaka/items/ae01990b147570fa0e75
using UnityEditor;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.IO;
public class SourceFileEcodingChecker : AssetPostprocessor {
static Regex m_SourceFilePattern;
@snaka
snaka / bomcheck.rb
Created July 2, 2014 12:04
BOM無しUTF-8のファイルをBOM付きで一括で保存し直す ref: http://qiita.com/snaka/items/2e2ec9961834f6629d69
dirs = ["./trunk/unity/Assets/Source/**/*.cs", "./trunk/unity/Assets/Editor/**/*.cs"]
dirs.each do |dir|
Dir.glob(dir).each do |f|
next unless File.file?(f)
hoge = open(f)
hoge.binmode
begin
if hoge.read(3).unpack("h*")[0] != "febbfb"
puts f.to_s #+ " is *NOT* BOM file"
@snaka
snaka / EditPlayerPrefs.cs
Created July 2, 2014 08:19
PlayerPrefs の値を編集するエディタ拡張 ref: http://qiita.com/snaka/items/37315d5eb47368a6bf56
using UnityEngine;
using UnityEditor;
using System.Collections;
public class EditPlayerPrefs : EditorWindow {
class PrefInfo {
public string Key;
public string Type;
}
@snaka
snaka / .vimrc
Last active September 28, 2017 03:04
vimとtmuxにpowerlineを導入する ref: http://qiita.com/snaka/items/c0c8760993f73780acbb
"================
" NeoBundle
"================
set nocompatible
filetype off
if has('vim_starting')
set runtimepath+=~/.vim/bundle/neobundle.vim
endif
@snaka
snaka / Autorun.cs
Created June 26, 2014 08:38
例外発生時にアプリを一時停止する ref: http://qiita.com/snaka/items/d062b6193b8dc884f324
using UnityEngine;
using System.Collections;
/// <summary>
/// Editorでのスクリプト起動時に初期化処理を実行
/// </summary>
[UnityEditor.InitializeOnLoad]
public class Autorun : MonoBehaviour {
static Autorun() {
Debug.Log ("*** Debug.Log hooked by Autorun.LogCallbackHandler()");
@snaka
snaka / MyWebView.cs
Created June 11, 2014 13:20
unity-webview で自前のHTMLを表示するサンプル ref: http://qiita.com/snaka/items/46042be015ad320d5f4b
using UnityEngine;
using System.Collections;
using System.IO;
public class MyWebView : MonoBehaviour {
// Inspector で画面上に配置した GUI Text にアタッチする
public GUIText DebugText;
string m_filePath;
@snaka
snaka / RSATest.cs
Created May 18, 2014 04:41
BouncyCastle で公開鍵暗号標準(RSA)を扱う ref: http://qiita.com/snaka/items/0829c37494b61353445e
using UnityEngine;
using System.IO;
using System.Text;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Encodings;
public class APITestMain : MonoBehaviour {
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.Collections.Generic;
public class TweenGroupManager : EditorWindow {
class TweenGroup {
public int GroupNo = 0;