Skip to content

Instantly share code, notes, and snippets.

@dskjal
dskjal / AutoBlink.cs
Last active September 24, 2016 12:32
ユニティちゃんの瞬きを滑らかにする
@dskjal
dskjal / unity_foreach_test.cs
Last active September 24, 2016 23:13
Unity は foreach でヒープにメモリを確保するか?
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour {
readonly int ARRAY_LENGTH = 1000;
int[] values;
GameObject[] objects;
void Awake() {
objects = new GameObject[ARRAY_LENGTH];
@dskjal
dskjal / InstancePool.cs
Last active September 26, 2016 03:10
Unity のプレハブをプールしておくコンテナ
// BEGIN MIT LICENSE BLOCK //
//
// Copyright (c) 2016 dskjal
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
//
// END MIT LICENSE BLOCK //
/* 使い方
public GameObject Prefab;
private InstancePool enemyPool;
@dskjal
dskjal / Coroutine.cs
Last active September 29, 2016 01:45
Unity でヒープにできるごみを減らすコルーチン
using UnityEngine;
using System.Collections;
public class Coroutine : MonoBehaviour {
[SerializeField]float interval = 1;
void Start () {
StartCoroutine(coroutine());
}
@dskjal
dskjal / VariableWaitForSeconds.cs
Created September 29, 2016 03:06
Unity でヒープにごみを出さない WaitForSeconds
// BEGIN MIT LICENSE BLOCK //
//
// Copyright (c) 2016 dskjal
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
//
// END MIT LICENSE BLOCK //
/* 使い方
[SerializeField]
float interval = 1;
@dskjal
dskjal / ItemDB.cs
Last active June 19, 2017 01:38
アイテムデータベースの例
struct ItemData{
int ItemID;
// その他のフィールド変数
}
class ItemDB{
private ItemData items[];
public ItemData this[int i]{
get{
return items[i]
}
@dskjal
dskjal / AbstructItem.cs
Last active November 14, 2016 19:17
アイテムの抽象化
enum ItemStatus{
Delete,
CannotUse
}
interface IItem{
ItemStatus Use();
//そのほかの GetName() のような便利なメソッド
}
@dskjal
dskjal / EffectStack.cs
Last active November 14, 2016 19:05
Effect Stack クラス
class PlayerData{
public int HP;
// そのほかのパラメータ
}
enum EffectStatus{
TimeOut
}
interface IEffect{
@dskjal
dskjal / generate.py
Last active December 25, 2016 07:43
Rigify show additional layer in picker
''' old code
# Create list of layer name/row pairs
layer_layout = []
for l in metarig.data.rigify_layers:
print( l.name )
layer_layout += [(l.name, l.row)]
end old code'''
# new code
# Create list of layer name/row pairs
@dskjal
dskjal / remove_modifier.py
Last active March 27, 2018 07:14
不要なモディフィアを削除するスクリプト
import bpy
#アクティブなアーマチュアのすべてが対象
for bone in bpy.context.active_object.pose.bones:
for c in bone.constraints:
#Constraint の名前で削除
if c.name == 'Limit Location':
bone.constraints.remove(c)
break
#Constraint の型で削除