Skip to content

Instantly share code, notes, and snippets.

View AsyncTest.cs
public class AsyncTest : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
// コルーチン実行
StartCoroutine(AsyncCoroutineCaller(() =>
{
// async/await実行
AsyncTaskCaller();
@afjk
afjk / gist:130b7c17f834ba72c3e31fcb8dd8a027
Created Jul 26, 2020
Linqで最初の要素を取得する。デフォルトはnull
View gist:130b7c17f834ba72c3e31fcb8dd8a027
List<bool> container = new List<bool>();
// containerに値セット
var item = container.FirstOrDefault(x => x == true );
@afjk
afjk / TargetClassInspector.cs
Created Jul 26, 2020
エディタ拡張:Inspectorにボタンを表示して対象クラスのPublicメソッドを呼び出す
View TargetClassInspector.cs
// Editorフォルダ配下に配置
using UnityEditor;
using UnityEngine;
namespace STYLY
{
[CustomEditor(typeof(TargetClass))]
public class TargetClassInspector : Editor
{
public override void OnInspectorGUI()
@afjk
afjk / ContextMenuExample.cs
Created Jul 25, 2020
UnityEditorExtension:Inspectorの右のメニューからのメソッド呼び出し
View ContextMenuExample.cs
[ContextMenu("FuncName")]
public void FuncName()
{
Debug.Log("FuncName called.");
}
View MazeMaker.cs
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;
View MazeMakerGrow.cs
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;
View MazeMakerGrowInObj.cs
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 Jan 25, 2015
iOS cocos3d cameraを端末の姿勢に合わせて制御する
View ios_cocos3d_device_camera.m
#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 Aug 29, 2015
変形CSL関数
View csl_motor.m
- (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 Aug 29, 2015
Defying Gravity - A Minimal Cognitive Sensorimotor Loop Which Makes Robots With Arbitrary Morphologies Stand Up からの引用
View CSL.v
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