Skip to content

Instantly share code, notes, and snippets.

@inoook
inoook / uOSCUtils.cs
Created September 23, 2024 09:30
uOSCのデータのbyte[] <-> Message変換
using System;
using System.IO;
using uOSC;
public static class uOSCUtils
{
/*
var bytes = uOSCUtils.ByteFromMsg(message);
Debug.LogWarning(bytes.Length);
// 再帰的に子オブジェクトを検索するメソッド
Transform FindChildByName(Transform parent, string childName)
{
// 現在の親オブジェクトの全ての子オブジェクトをループ
foreach (Transform child in parent)
{
// 子オブジェクトの名前が一致する場合、その子オブジェクトを返す
if (child.name == childName)
{
return child;
@inoook
inoook / MathExtend.cs
Created March 5, 2024 12:44
doubleを使用して精度を上げる
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// UnityのMathfをdoubleで行う。
/// 精度を上げるため
/// </summary>
public class MathExtend
using System;
using System.Threading;
using System.Threading.Tasks;
using UnityEngine;
public class TaskExtensions
{
/**
@inoook
inoook / AsyncEvent_Sample.cs
Created December 21, 2023 10:33
AsyncEvent_Sample.cs
/**
CancellationTokenSource eventActCts;
void Cancel_AsynEventTest()
{
if(eventActCts != null)
{
eventActCts.Cancel();
}
eventActCts = null;
@inoook
inoook / LeanTweenAsyncExtensions.cs
Created December 13, 2023 10:48
LeanTweenAsync
using UnityEngine;
using System.Threading.Tasks;
using System.Threading;
public static class LeanTweenAsyncExtensions
{
//public static async Task AwaitCompletionAsync(this LTDescr tween)
//{
// var tcs = new TaskCompletionSource<bool>();
// tween.setOnComplete(() => tcs.TrySetResult(true));
@inoook
inoook / Coordinates.cs
Created November 16, 2023 03:10
Equirectangular座標から球面の3D座標に変換する関数
/// <summary>
/// Equirectangular座標から球面の3D座標に変換する関数
/// </summary>
/// <param name="lon">経度(0から1の範囲)</param>
/// <param name="lat">緯度(0から1の範囲)</param>
/// <returns></returns>
Vector3 EquirectangularToSphereCoordinates(float lon, float lat)
{
float u = lon;
float v = lat;
@inoook
inoook / MeshTextureColorPicker.cs
Created November 10, 2023 12:24
UnityでMeshの色取得。subMesh対応
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class MeshTextureColorPicker : MonoBehaviour
{
/// <summary>
/// Meshをstaticにしているとbatchで結合されsubmeshIndexが異なり正常に取得できなくなる。
/// 対応方法 (対象となるMeshをBatchingの対応外にする)
using UnityEngine;
using System.Collections.Generic;
public class MainThreadDispatcher : MonoBehaviour
{
private static MainThreadDispatcher instance;
private static readonly object lockObject = new object();
private Queue<System.Action> actions = new Queue<System.Action>();
@inoook
inoook / CommandLineArgsUtils.cs
Last active April 26, 2023 12:02
CommandLineArgsUtils
using System;
using System.Linq;
using System.Reflection;
using UnityEngine;
public static class CommandLineArgsUtils
{
// https://github.com/baba-s/Kogane.CommandLineParser/tree/master/Editor
/**