Skip to content

Instantly share code, notes, and snippets.

@iwashihead
iwashihead / Shaker.cs
Created January 21, 2017 07:37
汎用シェイク処理
using System;
using UnityEngine;
using Random = UnityEngine.Random;
namespace hoge
{
/// <summary>
/// シェイク処理
/// </summary>
public class Shaker : IDisposable
@iwashihead
iwashihead / TextSizeAdjuster.cs
Created November 30, 2016 12:14
【Unity】【UI】テキストのサイズ調整を行うコンポーネントです
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// テキストのサイズ調整を行うコンポーネントです
/// </summary>
[ExecuteInEditMode]
[DisallowMultipleComponent]
[RequireComponent(typeof(Text))]
public class TextSizeAdjuster : MonoBehaviour
@iwashihead
iwashihead / CreateTextFileMenu.cs
Created November 21, 2016 02:40
【Unity】【Editor】 テキストファイルを作成するCreateMenu
using System;
using System.IO;
using UnityEngine;
using UnityEditor;
/// <summary>
/// 新規テキストファイルを作成する
/// EditorMenuスクリプトです
///
/// 使い方:
@iwashihead
iwashihead / file0.cs
Created October 12, 2016 05:37
【C#】nullチェックを楽にする演算子のオーバーロード ref: http://qiita.com/iwashihead/items/7757003712b64a1f6fa8
public class Hoge
{
public static implicit operator bool(Hoge self)
{
return self != null;
}
public static bool operator true(Hoge self)
{
return self != null;
@iwashihead
iwashihead / UnityActionWrapper.cs
Created October 3, 2016 09:10
UnityActionのイベントラッパークラス
using System.Collections.Generic;
using UnityEngine.Events;
namespace IW.UnityActionEvent
{
/// <summary>
/// Extensionメソッド郡.
/// </summary>
public static class UnityActionWrapperExtension
{
@iwashihead
iwashihead / RegexSample.cs
Created September 30, 2016 08:51
正規表現のサンプル
using System;
using UnityEngine;
using System.Collections;
using System.Text.RegularExpressions;
namespace Griphone.Agito.Sandbox
{
public class RegexSample : MonoBehaviour
{
// 正規表現のターゲット文字列.
@iwashihead
iwashihead / file0.cs
Created September 29, 2016 04:08
UnityActionのeventラッパークラス ref: http://qiita.com/iwashihead/items/dca4f721c93295ae9fe3
/*** 使用例 ***/
var OnDamage = new UnityActionWrapper<int>();
// ダメージ通知の関数を登録.
OnDamage += (damage) => { Player.SetDamage(damage); };
// 実際にダメージを与える
OnDamage.Invoke(100);
// ~~~ (略) ~~~
@iwashihead
iwashihead / EditorOperation.cs
Last active September 28, 2016 08:25
Project内のSceneやPrefabに対して一括処理を実行するヘルパースクリプト
using System;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Griphone.Agito.EditorExtension
{
@iwashihead
iwashihead / file0.cs
Created September 26, 2016 09:29
【Unity】Project内の全シーンに処理を実行する ref: http://qiita.com/iwashihead/items/07bc7a916d73b6d4e879
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;
using System;
using System.IO;
using System.Linq;
/// <summary>
/// シーン操作クラス
/// </summary>
@iwashihead
iwashihead / file0.cs
Created September 16, 2016 12:40
【Unity】アバターをまとめて1SetPassにする ref: http://qiita.com/iwashihead/items/e36fd5578643f8e146a9
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
public class RuntimeCharacterAtlasTest : MonoBehaviour
{
public Texture2D BodyTex;
public Texture2D HairTex;
public Texture2D EyeTex;