コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

2020-11-16から1日間の記事一覧

【Unity】特殊なフォルダを作成するメニューを追加するエディタ拡張「UniSpecialFolderCreator」を GitHub に公開しました

リポジトリ 使用例

【Unity】Caching の内容を JSON で出力できるようにするクラス

ソースコード

【Unity】ビルド時に EditorUserBuildSettings.activeScriptCompilationDefines を TextAsset に書き込むエディタ拡張

ソースコード

【Unity】UnityEngine.iOS.Device の内容を JSON で出力できるようにするクラス

ソースコード

【Unity】QualitySettings の内容を JSON で出力できるようにするクラス

ソースコード

【Unity】アプリを実行している端末の Android バージョンを取得する方法

ソースコード using UnityEngine; public static class AndroidUtils { public static int GetSdkInt() { #if UNITY_ANDROID if ( Application.isEditor ) return -1; using ( var version = new AndroidJavaClass( "android.os.Build$VERSION" ) ) { return…

【Unity】Your project path contains non-ASCII characters

概要 Your project path contains non-ASCII characters. This will most likely cause the build to fail on Windows. Please move your project to a different directory. See http://b.android.com/95744 for details. This warning can be disabled by …

【Unity】UnityWebRequestAsyncOperation の内容を JSON で出力できるようにするクラス

ソースコード 使用例 using Kogane; using System.Collections; using UnityEngine; using UnityEngine.Networking; public class Example : MonoBehaviour { private IEnumerator Start() { var request = UnityWebRequest.Get( "https://www.google.com/" …

【C#】文字列に含まれている改行やタブ文字などのエスケープ文字を変換する方法

C#

概要 var str = "{\n\t\\\"id\\\":25,\n\t\\\"name\\\":\\\"\\u30d4\\u30ab\\u30c1\\u30e5\\u30a6\\\"\n}"; Debug.Log( Regex.Unescape( str ) ); { "id":25, "name":"ピカチュウ" } Regex.Unescape を使用する

【Unity】Addressable Asset System ですべての Missing Reference なグループを削除するエディタ拡張

概要 using System.Reflection; using UnityEditor; using UnityEditor.AddressableAssets; using UnityEditor.AddressableAssets.Settings; public static class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { var settings = Addres…

【Unity】using を使用して OnDemandRendering.renderFrameInterval を設定するクラス

ソースコード 使用例 using Kogane; using System.Collections; using UnityEngine; using UnityEngine.Rendering; public class Example : MonoBehaviour { private void Update() { if ( Input.GetKeyDown( KeyCode.Space ) ) { StartCoroutine( Hoge() );…

【Unity】using を使用して Application.targetFrameRate を設定するクラス

ソースコード 使用例 using Kogane; using System.Collections; using UnityEngine; public class Example : MonoBehaviour { private void Update() { if ( Input.GetKeyDown( KeyCode.Space ) ) { StartCoroutine( Hoge() ); } } private IEnumerator Hoge…

【Unity】サスペンド・レジュームのイベントを管理するクラスを自作する

ソースコード 使用例 using Kogane; using UnityEngine; public sealed class Example : MonoBehaviour { private void Awake() { GlobalApplicationEvent.OnPause += OnGlobalApplicationEventOnOnPause; } private void OnDestroy() { GlobalApplicationEv…

【Unity】iOS で SFSafariViewController を使用する方法

はじめに 上記のフォーラムで公開されているスクリプトを使用することで iOS で SFSafariViewController を使用できるようになります この記事では上記のスクリプトを参考に iOS で SFSafariViewController を使用できるようにする方法を紹介していきます 検…

【Unity】Android で Chrome Custom Tabs を使用する方法

はじめに 基本的には上記サイト様が紹介してくださっている手順を踏めば Android で Chrome Custom Tabs を使用できるようになりますが、 いくつか躓いた箇所があったため、備忘録として自分が踏んだ手順をまとめておきます 検証環境 Unity 2020.1.6f1 手順 …

【Unity】UnityWebRequest で JSON を POST 通信するサンプル

概要 using System; using System.Text; using UnityEngine; using UnityEngine.Networking; public class Example : MonoBehaviour { [Serializable] private sealed class Data { public int id = 25; public string name = "ピカチュウ"; } private void …