コガネブログ

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

2022-10-01から1ヶ月間の記事一覧

【Unity】検索中は Project ウィンドウにアセットのフォルダ名を表示するエディタ拡張

リポジトリ 使用例

【Unity】Device Simulator にデバイスの情報を表示するエディタ拡張

リポジトリ 使用例

【Unity】Failed to register for remote notifications

概要 Firebase Cloud Messaging を導入した Unity プロジェクトを iOS ビルドして動作確認したところ Failed to register for remote notifications 上記のエラーが発生する現象に遭遇した Mobile Notifications パッケージの Project Settings で 「Enable …

【Unity】Firebase.FirebaseException: We have blocked all requests from this device due to unusual activity. Try again later.

概要 Firebase.FirebaseException: We have blocked all requests from this device due to unusual activity. Try again later. FirebaseUser.SendEmailVerificationAsync を何回か試していたら 途中から上記の例外が発生して動作確認ができなくなってしま…

【Unity】Firebase.FirebaseException: The email address is badly formatted.

概要 Firebase.FirebaseException: The email address is badly formatted. FirebaseAuth.SignInWithEmailAndPasswordAsync を使用した時に 上記の例外が発生する現象に遭遇した パスワードの文字列をよく見てみたらアットマーク @ が 半角ではなく全角にな…

【Unity】Device Simulator の Control Panel にデバイスを変更するボタンを追加するエディタ拡張

リポジトリ 使用例

【Unity】Device Simulator にデバイスのブックマーク機能を追加するエディタ拡張

リポジトリ 使用例 「Add Bookmark」を押すと現在使用しているデバイスをブックマークできます ブックマークしたデバイスを選択すると即座にそのデバイスに切り替えられます

【Unity】GvhProjectSettings.xml が勝手に変更される

概要 Firebase を導入した Unity プロジェクトで GvhProjectSettings.xml が勝手に変更される 現象に遭遇した 公式の GitHub で Issue が作られていたが、まだ解決していないようだった 検証環境 Unity 2022.1.11f1 macOS Monterey バージョン 12.5.1 MacBoo…

【Unity】3D 空間に配置した TextMesh Pro に SpriteMask を適用する方法

概要 TextMesh Pro のマテリアルを選択して Stencil ID を 1、Stencil Comp を 3 にすることで ワールド空間に配置した TextMesh Pro に SpriteMask を適用できます Stencil ID を 0 にすると逆マスクになります 参考サイト様 You can use SpriteMask with T…

【Unity】3D Object の TextMesh Pro の色が正しく反映されない場合の対処方法

はじめに Vertex Color に設定した色より薄く表示される 3D Object の TextMesh Pro は Vertex Color に設定した色が 正しく反映されないことがあるのでその対処方法 目次 はじめに 目次 検証環境 対処方法1:TextMesh Pro を 3.2.0-pre.3 にアップデートす…

【Unity】ArgumentException: Can't save a Prefab instance

概要 PrefabUtility.SavePrefabAsset( prefab ); PrefabUtility.SavePrefabAsset でプレハブを保存しようとして ArgumentException: Can't save a Prefab instance 上記のエラーが発生する場合は PrefabUtility.SaveAsPrefabAsset( prefab, prefabPath ); Pr…

【Unity】Calling OnPostBuildPlayerScriptDLLs callbacks. For faster build speeds, consider not using this callback, as we don't need to copy assemblies to the staging area for the incremental player build otherwise.

概要 Calling OnPostBuildPlayerScriptDLLs callbacks. For faster build speeds, consider not using this callback, as we don't need to copy assemblies to the staging area for the incremental player build otherwise. ビルド時に上記のログが出力さ…

【Unity】マウスカーソルの場所に Tooltip を表示できるエディタ拡張

リポジトリ 使用例 using Kogane; using UnityEditor; public static class Example { [MenuItem( "Assets/Hoge" )] public static void Hoge() { TooltipWindow.Open( "ピカチュウ" ); } }

【Unity】JNI:GetAudioStreamVolume:java.lang.SecurityException: listen

概要 JNI:GetAudioStreamVolume:java.lang.SecurityException: listen Unity 2022.1.11f1 で Android ビルドしたところ アプリ起動直後に上記のエラーログが出力されていた 最新の Unity バージョンなら直っているようだったので Unity 2022.1.20f1 で Andro…

【Unity】Console ウィンドウに検索ボタンを表示するエディタ拡張

リポジトリ 使用例 Console ウィンドウで検索したいテキストを Project Settings で設定します 項目 内容 Button Text ボタンに表示するテキスト Filtering Text ボタンを押した時に検索欄に入力するテキスト未入力ならボタンを押した時に Button Text に設…

【Unity】The operation couldn't be completed. Unable to locate a Java Runtime.

概要 Gradle failed to fetch dependencies. Failed to run 'XXXX/UnityProject/Temp/PlayServicesResolverGradle/gradlew --no-daemon -b "XXXX/UnityProject/Temp/PlayServicesResolverGradle/PlayServicesResolver.scripts.download_artifacts.gradle" "-…

【Unity】FirebaseCppApp-9_6_0.bundle が 100 MB を超えており GitHub リポジトリに Push できない場合

概要 remote: error: See http://git.io/iEPt8g for more information. remote: error: File UnityProject/Assets/Firebase/Plugins/x86_64/FirebaseCppApp-9_6_0.bundle is 134.36 MB; this exceeds GitHub's file size limit of 100.00 MB remote: error: …

【Unity】Firebase を使っているプロジェクトの iOS ビルドで .xcworkspace ではなく .xcodeproj を生成する方法

概要 Unity メニューの「Assets > External Dependency Manager > iOS Resolver > Settings」の 「Cocoapods Integration」を「Xcode Project~」にすると iOS ビルドで .xcworkspace ではなく .xcodeproj が生成されるようになる

【Unity】Execution failed for task ':launcher:processReleaseResources'.

概要 CommandInvokationFailure: Gradle build failed. C:\Program Files\Unity\Hub\Editor\2022.1.11f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2022.1.11f1\Editor\Data\Playback…

【Unity】Android で署名なしでビルドする時に使用されるデバッグ用の keystore の保存場所

概要 OS 場所 Mac /Users/【ユーザー名】/.android/debug.keystore Windows C:\Users\【ユーザー名】\.android\debug.keystore 参考サイト様 The unsigned debug keystore is located by default at ~/.android/debug.keystore on MacOS and %USERPROFILE%.a…

【Unity】iOS framework addition failed due to a CocoaPods installation failure. This will will likely result in an non-functional Xcode project.

概要 iOS framework addition failed due to a CocoaPods installation failure. This will will likely result in an non-functional Xcode project. After the failure, "pod repo update" was executed and failed. "pod install" was then attempted aga…

【Unity】Android 13 で通知許可ダイアログを開く方法

Mobile Notifications を使う方法 Mobile Notifications 2.1.0 を使えば簡単に実装できる Mobile Notifications 2.1.0 を使用して Android 13 で通知許可ダイアログを開く方法は上記のページの 「Request permission to post notifications」に記載されてい…

【Unity】Android 13 で通知許可ダイアログを開く時に無限ループが発生してしまう場合

概要 Mobile Notifications 2.1.0 を使用して Android 13 で通知許可ダイアログを開く時に 無限ループが発生してしまう場合、 「Project Settings > Player > Target API Level」を「API level 33」にしてから ビルドし直すと通知許可ダイアログが正常に開け…

【Unity】Notifications are not allowed for this application

はじめに Mobile Notifications を使用して iOS で通知許可ダイアログを表示しようとしたところ Notifications are not allowed for this application Requesting notification authorization failed with: Error Domain=UNErrorDomain Code=1 "Notification…

【Unity】iOS ビルド時に Xcode プロジェクトの Product Name を変更するエディタ拡張

ソースコード #if UNITY_IOS using UnityEditor; using UnityEditor.Callbacks; using UnityEditor.iOS.Xcode; internal static class Example { [PostProcessBuild] private static void OnPostProcessBuild ( BuildTarget buildTarget, string pathToBuilt…

【Unity】Inspector のコンポーネントのヘッダーにボタンを追加するエディタ拡張

リポジトリ 使用例 Remove Component Move Up / Move Down Copy Component / Paste Component Values

【Unity】EventSystem の情報をいつでも見られるようにする EditorWindow

リポジトリ 使用例 Unity メニューの「Window > Kogane > Event System Status」を選択すると EventSystem の情報をいつでも確認できるようになるため 現在どのオブジェクトをクリックしているかなどが常に確認できます

【Unity】Non-secure network connections disabled in Player Settings

概要 Non-secure network connections disabled in Player Settings System.Reflection.MethodBase:Invoke (object,object[]) Google.PortableWebRequest:StartRequest (Google.PortableWebRequest/HttpMethod,string,System.Collections.Generic.IDictionar…

【Unity】インスタンス ID からゲームオブジェクトやアセットを取得する方法

エディタ拡張の場合 var obj = EditorUtility.InstanceIDToObject( instanceId ); EditorUtility.InstanceIDToObject を使用する ランタイムの場合 public static Object FindObjectFromInstanceID( int instanceId ) { var type = typeof( Object ); var me…

【Unity】ObjectChangeEvents を使えば Unity エディタの様々なイベントを検知できる

概要 using UnityEditor; using UnityEngine; [InitializeOnLoad] public static class Example { static Example() { ObjectChangeEvents.changesPublished += ( ref ObjectChangeEventStream stream ) => { Debug.Log( "changesPublished" ); }; } } Objec…