Skip to content

Instantly share code, notes, and snippets.

using UnityEditor;
using System.Linq;
using UniRx;
[CustomEditor(typeof(ObserveTransition))]
public class ObserveTransitionInspector : Editor {
public override void OnInspectorGUI()
{
serializedObject.Update();
var transition = serializedObject.targetObject as ObserveTransition;
@adarapata
adarapata / mosaic.shader
Last active June 5, 2016 21:54
角の色に合わせるタイプのモザイクシェーダ
Shader "Custom/Mosaic" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_MosaicScale ("Mosaic", Range(0.01, 10)) = 1
}
SubShader {
Pass {
GLSLPROGRAM
#ifdef VERTEX
varying vec2 vUv;
@adarapata
adarapata / timer.cs
Created January 28, 2014 01:50
Unityの自作タイマー
using UnityEngine;
using System;
using System.Collections;
/// <summary>
/// 全てのTimerクラスをupdateさせる
/// </summary>
public class TimerExecutor : MonoBehaviour {
public event Action timeUpdate;
@adarapata
adarapata / file0.cs
Created December 17, 2013 15:00
2Dアニメーションのメソッド呼び出しが凄く便利 ref: http://qiita.com/adarapata/items/e132b66dd9cfa1acedd6
public class AnimationObserver : MonoBehaviour {
public Action animationEndNotify;
public void Notify()
{
if(animationEndNotify != null)animationEndNotify();
}
}
@adarapata
adarapata / gist:6714746
Created September 26, 2013 14:08
ngui3,0.0
  • UISlicedSprite, UITiledSprite, UIFilledSprite の削除。UISpriteの中にそれぞれの機能が入ってる

  • スプライト名をリネームしやすくなった(renameボタンがついた)

  • スプライト一覧画面にスプライト名が出てる

  • IgnoreTimeScaleを削除して、代わりにRealTimeクラスが追加。現実時間はこっちから取ると良いらしい

  • UISpriteのプロパティに "Dimensions" が追加。前まで画像のピクセル数がtransform.localscaleに入ってたけど、ピクセル数はDimensions、倍率がtransform.localscaleに入るようになってる。

  • TweenWidth と TweenHeight が追加。Dimensionsの値(それぞれ横幅と縦幅)を動的に変える。UISpriteがアタッチされてないオブジェクトに付けるとnullエラー

  • eventReciever周りが大きく変更

  • 名称がnotifyに変更

  • 文字列で直接メソッド名を書いていたのが、対象のオブジェクトのpublicなメソッドをプルダウンリストで選択できるようになった。逆に、privateなメソッドは呼び出せなくなった。

@adarapata
adarapata / gist:6284054
Created August 20, 2013 16:50
has_oneっぽいもの
using System.Collections;
using System;
public class HasOne<T> where T : IDataAccessObject, new()
{
public T node { get; set; }
public HasOne(Func<T, bool> predicate)
{
node = AcitiveRecord<T>.Find(predicate);
}
@adarapata
adarapata / gist:6256039
Created August 17, 2013 09:10
SelectしかできてないActiveRecord for C#
using UnityEngine;
using System.Collections;
using System.Linq;
using System.Collections.Generic;
using System;
public class AcitiveRecord<T> where T : IDataAccessObject, new()
{
static protected MyDatabase db;
@adarapata
adarapata / gist:5744196
Last active December 18, 2015 07:09
xml尻洗い図
using System.Collections;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
/// <summary>
/// クラスオブジェクトとxmlをシリアライズ・デシリアライズするクラス
/// </summary>
public static class MyXmlSerializer
{
@adarapata
adarapata / gist:5715085
Created June 5, 2013 16:04
カーソル
/// <summary>
/// コンテンツを選択するカーソルインタフェース
/// </summary>
public interface ICursol
{
/// <summary>
/// 現在選択中のコンテンツ
/// </summary>
ICursolContent content { set; get; }
/// <summary>
@adarapata
adarapata / gist:5632149
Last active December 17, 2015 15:29
席替えスクリプト
using System;
using System.Collections.Generic;
class Program
{
static void Main(string[] args)
{
string[] sankisei = { "ぐっさん", "おっくん", "きたけー", "たけお"};
List<string> shuffle = new List<string>();
Ramdom r = new Random();