概要 public struct Example : IJob { void IJob.Execute() { var list = new NativeList<int>( Allocator.Persistent ); } } 上記のように IJob.Execute の中で Allocator.Persistent を指定して NativeList を生成したら System.InvalidOperationException: Job</int>…
概要 (0,0): Burst error BC1045: Struct `XXXX&` with auto layout is not supported IJob インターフェイスを実装する構造体を定義した際に 上記のエラーが発生する現象に遭遇した public (int, int) value { get; set; } 上記のように ValueTuple を使用…
概要 Package Manager で「Collections」パッケージをインストールすると使えるようになる
概要 「WhatUsesThisInScene」を Unity プロジェクトに導入することで ゲームオブジェクトが依存しているアセットを確認できるようになります 使い方 Hierarchy でゲームオブジェクトを右クリックして 「What uses this in the scene?」を選択すると ゲーム…
概要 「Speech And Text in Unity iOS and Unity Android」を Unity プロジェクトに導入することで iOS / Android で音声合成(TextToSpeech)使用できるようになります 使い方 using TextSpeech; using UnityEngine; public class Example : MonoBehaviour …
概要 「Unity-EasingAnimationCurve」を Unity プロジェクトに導入することで Ease を AnimationCurve で使用できるようになります 使い方 GitHub リポジトリに含まれている「EasingFunctions.curves」を Unity プロジェクトの Editor フォルダに追加します …
概要 Unity で作成した Android アプリを「arrows Tab F-02K」にインストールしたら Audio がすごくスローで再生される現象に遭遇した Unity の「Project Settings > Audio」で 「DSP Buffer Size」を「Best latency」から「Best performance」に変えたら 正…
概要 using System.Collections.Generic; using UnityEngine; public class Example : MonoBehaviour { private void Awake() { var spriteRenderer = GetComponent<SpriteRenderer>(); var sprite = spriteRenderer.sprite; var polygonCollider2D = GetComponent<PolygonCollider2D>(); var ph</polygoncollider2d></spriterenderer>…
概要 if ( AssetDatabase.TryGetGUIDAndLocalFileIdentifier( instanceId, out var guid, out long localId ) ) { Debug.Log( guid ); Debug.Log( localId ); } AssetDatabase.TryGetGUIDAndLocalFileIdentifier を使用する
リポジトリ 導入前 導入後
リポジトリ 使用例 iOSSilentModePlayAudio.SetAudioSession(); 上記の関数を任意のタイミングで呼び出します
概要 using UnityEngine; using UnityEngine.EventSystems; public class Example : MonoBehaviour, IPointerClickHandler { void IPointerClickHandler.OnPointerClick( PointerEventData eventData ) { if ( 0 < eventData.pointerId ) return; Debug.Log(…
概要 ファイル名の末尾が数字のアセットを複製すると デフォルトでは上記のようになってしまうが Project Settings の「Editor > Space Before Number in Asset Names」をオフにすると ファイル名の連番が正しく計算されるようになります
リポジトリ 使用例 using Kogane; using UnityEngine; public class Example : ObsoleteMonoBehaviour { private void Start() { Debug.Log( name ); Debug.Log( enabled ); Debug.Log( transform ); Debug.Log( GetComponent<Transform>() ); } }</transform>
リポジトリ 使用例 using System.Threading; using Cysharp.Threading.Tasks; using Kogane; using UnityEngine; public class Example : MonoBehaviour { private readonly CancellationTokenSource m_cancellationTokenSource = new(); private async UniT…
リポジトリ 使用例 Before using System; using Cysharp.Threading.Tasks; using UnityEngine; public class Example : MonoBehaviour { private async UniTaskVoid Start() { await UniTask.Delay( TimeSpan.FromSeconds( 1 ) ); } } After using System; u…
概要 「Editor-View-UnityDomainReloadHelper」を Unity プロジェクトに導入することで Enter Play Mode で static 変数の初期化ができる Attribute を使えるようになります 使い方 using UnityEngine; public class Example : MonoBehaviour { // 0 で初期…
概要 「Editor-View-TransformChanged helper」を Unity プロジェクトに導入することで Transform が変化したことを検知できるようになります 使い方 using Needle.TransformExtensions; using UnityEngine; public class Example : MonoBehaviour { private…
概要 「Custom Console Hyperlink handling for Unity」を Unity プロジェクトに導入することで ハイパーリンク付きのログ出力ができるようになります ハイパーリンクを付与する方法 using Needle; using UnityEngine; public class Example : MonoBehaviour…
概要 項目 ビルド時間 導入前 1 分 29 秒 導入後 2 分 43 秒 検証環境 Unity 2022.1.23f1 macOS Monterey バージョン 12.5.1 MacBook Pro 2021 Android Mono2x ビルド
概要 Caused by android.app.RemoteServiceException$CannotDeliverBroadcastException: can't deliver broadcast at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:1979) at android.app.ActivityThread.-$$Nest$mthrowRemo…
実行順 InitializeOnEnterPlayMode RuntimeInitializeLoadType.SubsystemRegistration RuntimeInitializeLoadType.AfterAssembliesLoaded RuntimeInitializeLoadType.BeforeSplashScreen RuntimeInitializeLoadType.BeforeSceneLoad RuntimeInitializeLoadTy…
概要 Project Settings の「Player > Static Splash Image」に単色の画像を設定して 「Scaling」を「Scale to fill (cropped)」にすることで Android アプリ起動時の色を変えることができる
検証環境 Unity 2022.1.23f1 Android 13 前提条件 Firebase Console にプロジェクトを作成済みで 「google-services.json」を Assets フォルダに導入済みだと想定しています Android に Switch Platform Android に Switch Platform しておきます パッケージ…
リポジトリ 使用例 Before using System; using System.Collections.Generic; using Cysharp.Threading.Tasks; using UnityEngine; public class Example : MonoBehaviour { private async UniTaskVoid Start() { var list = new List<UniTask>(); for ( var i = 0; i </unitask>…
概要 上記のページを開いて「Download package」を押して ダウンロードした .nupkg を ZIP で展開して、展開したフォルダ内の 「analyzers\dotnet\cs\IDisposableAnalyzers.dll」を Unity プロジェクトに追加して すべてのチェックを外して「Apply」を押して…
概要 Project Settings の「Audio > DSP Buffer Size」を 「Best latency」から「Best performance」にしたら音割れしなくなった
リポジトリ 使用例 using Cysharp.Threading.Tasks; using Kogane; using UnityEngine; public sealed class Example : MonoBehaviour { private async UniTaskVoid Star() { UniTask Impl1() => UniTask.CompletedTask; UniTask<bool> Impl2() => UniTask.FromRes</bool>…
【Unity】java.lang.IllegalArgumentException: Unknown permission: android.permission.POST_NOTIFICATIONS
概要 var tcs = new UniTaskCompletionSource<string>(); var callbacks = new PermissionCallbacks(); callbacks.PermissionGranted += _ => tcs.TrySetResult( "PermissionGranted" ); callbacks.PermissionDenied += _ => tcs.TrySetResult( "PermissionDenied" )</string>…
概要 using System; using UnityEngine; using UnityEngine.Networking; public class Example : MonoBehaviour { [Serializable] private sealed class Data { public int id = 25; public string name = "ピカチュウ"; } private void Awake() { var url =…