Skip to content

Instantly share code, notes, and snippets.

Avatar

Shunsuke Ohba baobao

View GitHub Profile
@baobao
baobao / UnityMicRecording.cs
Last active Sep 11, 2020
Unityで録音し、メモリ上に保持した録音サウンドを再生するサンプルコード
View UnityMicRecording.cs
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Unityで録音し、メモリ上に保持した録音サウンドを再生するサンプルコード
/// OnGUIでデバッグボタンを表示しています
/// </summary>
public class UnityMicRecording : MonoBehaviour
{
/// <summary>
View serial-microbit.js
// setup serial
serial.setBaudRate(BaudRate.BaudRate115200)
// 0:none, 1:Success, 2:Fail
basic.forever(function ()
{
let str = serial.readString()
if (str.indexOf("1") >= 0) {
basic.showIcon(IconNames.Heart)
basic.pause(1000)
@baobao
baobao / RenameTxt2Cs.csx
Created Aug 1, 2020
Rename Sample `.txt` to `.cs`
View RenameTxt2Cs.csx
#!/usr/bin/env dotnet-script
/**
* Rename Sample .txt to .cs
*/
if (Args == null || Args.Count < 0)
{
Console.WriteLine("Require arguments");
return;
}
@baobao
baobao / Janken.c
Created May 3, 2020
Cでじゃんけんゲーム
View Janken.c
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<unistd.h>
// じゃんけんの手
char te[3][20] = {"グー", "チョキ", "パー"};
int main()
{
View PrefabModeTest.cs
using UnityEngine;
public class PrefabModeTest : MonoBehaviour
{
void Awake()
{
Debug.Log($"Awake : Prefabモードのワタシ {this}", this);
}
void OnEnable()
View DOTweenAwaiterExtensionWithCancel.cs
using System;
using System.Threading;
using System.Threading.Tasks;
using DG.Tweening;
using UnityEngine;
// DOTweenAwaiterExtensionサンプルコード(キャンセル有り)
public class DOTweenAwaiterExtensionWithCancel : MonoBehaviour
{
async void Start()
View DOTweenAwaiterExtensionSample.cs
using System;
using System.Threading;
using System.Threading.Tasks;
using DG.Tweening;
using UnityEngine;
// DOTweenAwaiterExtensionサンプルコード(キャンセル処理なし)
public class DOTweenAwaiterExtensionSample : MonoBehaviour
{
async void Start()
View DOTweenAwaiterExtension.cs
using System;
using System.Runtime.CompilerServices;
using System.Threading;
using DG.Tweening;
using UnityEngine;
/// <summary>
/// DOTweenをasync/awaitに返還すDOTweenAwaiterの拡張メソッド
/// </summary>
public static class DOTweenAwaiterExtension
View MyTaskCancel.cs
using System;
using System.Threading;
using System.Threading.Tasks;
using UnityEngine;
public class MyTaskCancel : MonoBehaviour
{
// タスクをキャンセルさせるためのCancellationTokenSource
private CancellationTokenSource _cts;
View TaskDelayCacncel.cs
using System;
using System.Threading;
using System.Threading.Tasks;
using UnityEngine;
public class TaskDelayCacncel : MonoBehaviour
{
// タスクをキャンセルさせるためのCancellationTokenSource
private CancellationTokenSource _cts;
You can’t perform that action at this time.