Skip to content

Instantly share code, notes, and snippets.

public class AsyncTest : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
// コルーチン実行
StartCoroutine(AsyncCoroutineCaller(() =>
{
// async/await実行
AsyncTaskCaller();
@afjk
afjk / gist:130b7c17f834ba72c3e31fcb8dd8a027
Created July 26, 2020 02:47
Linqで最初の要素を取得する。デフォルトはnull
List<bool> container = new List<bool>();
// containerに値セット
var item = container.FirstOrDefault(x => x == true );
@afjk
afjk / TargetClassInspector.cs
Created July 26, 2020 01:29
エディタ拡張:Inspectorにボタンを表示して対象クラスのPublicメソッドを呼び出す
// Editorフォルダ配下に配置
using UnityEditor;
using UnityEngine;
namespace STYLY
{
[CustomEditor(typeof(TargetClass))]
public class TargetClassInspector : Editor
{
public override void OnInspectorGUI()
@afjk
afjk / ContextMenuExample.cs
Created July 25, 2020 23:43
UnityEditorExtension:Inspectorの右のメニューからのメソッド呼び出し
[ContextMenu("FuncName")]
public void FuncName()
{
Debug.Log("FuncName called.");
}
using UnityEngine;
using System.Collections;
public class MazeMaker : MonoBehaviour {
public delegate void MazeMakerEventHandler(object sender );
public event MazeMakerEventHandler MakeComplete;
public int randomSeed = -1;
public int xMax;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MazeMakerGrow : MonoBehaviour {
public bool growOnStart = false;
public int xMax = 11;
public int yMax = 11;
public int zMax = 11;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MazeMakerGrowInObj : MonoBehaviour {
public bool growOnStart = false;
public int xMax = 11;
public int yMax = 11;
public int zMax = 11;
@afjk
afjk / ios_cocos3d_device_camera.m
Created January 25, 2015 03:40
iOS cocos3d cameraを端末の姿勢に合わせて制御する
#import <CoreMotion/CoreMotion.h>
-(void) initMotionManager{
// 1.CMMotionManagereより、端末の姿勢情報を取得
_motionManager = [[CMMotionManager alloc] init];
// 更新の間隔を設定する
_motionManager.deviceMotionUpdateInterval = 1.0f / 30.0f;
// ハンドラを設定する
CMDeviceMotionHandler deviceMotionHandler;
@afjk
afjk / csl_motor.m
Last active August 29, 2015 14:04
変形CSL関数
- (void) doMonitoring{
// Δφ0(t)=-gi/K*Δφ1(t)+gf*Δφ0(t-1)
const float gi = 0.5f;
const float gf = 1.4f;
const float Kinv = 10.0f;
const float MAX_VOL = 2.0f; //角速度最大値
// 現在の角度
btScalar angle = pHinge->getHingeAngle();
@afjk
afjk / CSL.v
Last active August 29, 2015 14:02
Defying Gravity - A Minimal Cognitive Sensorimotor Loop Which Makes Robots With Arbitrary Morphologies Stand Up からの引用
reg [17:0] voltage;
reg [16:0] timer;
always @(posedge ADC_CLK)
case (state)
0 : begin // sense -----------------------------------
if (ADC_DAT == 1)
begin
if ($signed(voltage) < $signed(18'h1FFFF))
voltage <= voltage + 1; // if not saturated
end