Skip to content

Instantly share code, notes, and snippets.

View anzfactory's full-sized avatar
:octocat:
Working from home

anz anzfactory

:octocat:
Working from home
View GitHub Profile
@anzfactory
anzfactory / Array+App.swift
Created February 21, 2015 17:57
SwiftでObjective-Cの[NSarray removeObject:]てきなやつをする
extension Array {
mutating func removeObject<E: Equatable>(object: E) -> Array {
for var i = 0; i < self.count; i++ {
if self[i] as E == object {
self.removeAtIndex(i)
break
}
}
return self
}
@anzfactory
anzfactory / Bar.cs
Last active August 29, 2015 14:19
[Unity]HPバーっぽいものを実装してみた
using UnityEngine;
using UnityEngine.UI;
using System;
using BarCallback = System.Action<Bar>;
public class Bar : MonoBehaviour {
/// <summary>
/// 値を表現するスライダー
@anzfactory
anzfactory / SymbolReplacer.cs
Last active August 29, 2015 14:20
Unityでフォルダ階層にしたがってnamespaceをシンボル置換してくれるスクリプト
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class SymbolReplacer : UnityEditor.AssetModificationProcessor {
public static void OnWillCreateAsset (string path) {
@anzfactory
anzfactory / TiledMap.cs
Last active August 29, 2015 14:22
[Unity]TiledMapEditorで作ったファイルを読み込んでタイルを敷き詰めるスクリプト群 ( http://anz-note.tumblr.com/post/120453126046/unity-tiledmap )
/*********************************
2015-05-31 TiledMapデータ
(.xmlの要素に従って配置)
*********************************/
using System.Collections.Generic;
using System.Xml.Serialization;
using UniLinq;
[XmlRoot("map")]
public class TiledMap
/*********************************
#CREATED#
*********************************/
using UnityEngine;
namespace #NAMESPACE#
{
public class #SCRIPTNAME# : MonoBehaviour
{
@anzfactory
anzfactory / Notification.cs
Last active August 29, 2015 14:22
通知管理(車輪の再発明感!)
// 通知する情報そのもの
public class Notification
{
// 通知のタイプ(どんどん拡張させていく)
public enum Keys {
GameOver,
StageClear
}
private Keys key;
@anzfactory
anzfactory / AbstractData.cs
Last active August 29, 2015 14:23
オートマチックにデータクラスへデータをセットするやつ
using System;
using System.Collections.Generic;
namespace App.Data {
// データクラス基底
abstract public class AbstractData
{
public void Setup(Dictionary<string, object>data)
{
@anzfactory
anzfactory / ListSearchBar.swift
Last active August 29, 2015 14:23
UISearchBarにリストをくっつけてみた...なんか標準機能だけで出来そうな気もするけど
import UIKit
class ListSearchBar: UISearchBar, UISearchBarDelegate, UITableViewDataSource, UITableViewDelegate {
var myDelegate: UISearchBarDelegate? = nil
lazy var tableView: UITableView = self.setupTableView()
private var items = [String]()
private var isShowList = false
private var listHeight: CGFloat = 0.0
@anzfactory
anzfactory / hoge.cs
Created June 25, 2015 02:56
itween callback sample
public class Hoge : MonoBehaviour {
void MoveA ()
{
Action callback = () => {
// 何か処理
};
iTween.MoveBy (gameObject, iTween.Hash("y",1f,"time",0.5f, "oncomplete", "Fin", "oncompleteparams", callback));
}
void MoveB ()
{
@anzfactory
anzfactory / ScrollController.cs
Last active November 6, 2015 03:00
ScrollRectのスクロールチェンジをユーザー操作以外の場合は上部固定にするやつ
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class ScrollController : MonoBehaviour, IInitializePotentialDragHandler, IEndDragHandler
{
public enum ScrollState {
Wait,
BeginDrag,
EndDrag