コガネブログ

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

2018-09-01から1ヶ月間の記事一覧

【Unity】Visual Studio で Debug.Log の記述を楽にするコードスニペットを作成しました

はじめに 上記の GitHub で公開されている「Unity Code Snippets for Visual Studio」フォルダを Visual Studio のコードスニペットに追加することで Debug.Log の記述を楽にするコードスニペットを使用できるようになります 使い方 Log や LogFormat と入力…

【Unity】Unity の機能を async / await で使用できる「Await Extensions」紹介(無料)

概要 2018/9/14 に「Await Extensions」がリリースされました 「Await Extensions」を導入すると、 Unity の機能を async / await で使用できるようになります 検証環境 Unity 2017.4.7f1 Await Extensions 1.0 使用例

【Unity】uGUI のコードを変更して使用する方法

はじめに https://bitbucket.org/Unity-Technologies/ui/src uGUI のソースコードは Bitbucket で公開されているため、 自分で編集して使用することができます 変更例 https://bitbucket.org/Unity-Technologies/ui/downloads/ 上記のページにアクセスして「…

【Unity】MaskableGraphic を継承した uGUI コンポーネントは初期化や破棄のタイミングで GC Alloc が走る?

はじめに https://bitbucket.org/Unity-Technologies/ui/src/2017.3/UnityEngine.UI/UI/Core/MaskableGraphic.cs protected override void OnEnable() { ... if (GetComponent<Mask>() != null) { MaskUtilities.NotifyStencilStateChanged(this); } } protected o</mask>…

【Visual Studio】コードスニペットを追加する方法

方法1 C:\Users\【ユーザー名】\Documents\Visual Studio 2017\Code Snippets\【言語】\My Code Snippets 上記のフォルダに .snippet を追加します もしくは .snippet が格納されているフォルダを追加します 方法2 Visual Studio のメニューの「ツール>コー…

【Visual Studio】作成したスニペットを使用した時に最初に改行されてしまう現象の修正方法

概要 作成したスニペットを使用した時に最初に改行されてしまう場合、 <Code Language="csharp"></Code> スニペットテキストのどこかに <Code Language="csharp"></Code> 「$end$」と記述することで 参考サイト様

【Unity】Error Code: 1 occurred while Loading the [XXXX] font file. This typically results from the use of an incompatible or corrupted font file.

概要 Error Code: 1 occurred while Loading the [XXXX] font file. This typically results from the use of an incompatible or corrupted font file. TextMesh Pro で FontAsset を作成しようとした時に上記のエラーが発生した フォントのファイル名に日…

【Git】はてなブログに GitHub のコードを埋め込む方法

概要 <script src="http://gist-it.appspot.com/http://github.com/【GitHub のコードの URL】"></script> 上記のコードをはてなブログの記事に記述します (【GitHub のコードの URL】の部分を書き換えます) 補足 上記のコードは「gits-it」というサービスを使用しています http://gist-it.appspot.com/

【Git】Visual Studio でバージョン管理する必要がないファイルを定義した .gitignore

概要 参考サイト様

【Git】Unity でバージョン管理する必要がないファイルを定義した .gitignore

概要 参考サイト様

【Git】Microsoft Office の一時ファイルやバックアップファイルを無視する .gitignore

概要 参考サイト様

【Unity】ランプテクスチャにより色が変化するシェーダを導入する

はじめに http://www.shaderslab.com/demo-42---varying-color-with-ramp-texture.html この記事では上記のサイト様が公開されている ランプテクスチャにより色が変化するシェーダを導入する方法を紹介していきます 使用例 使い方 上記のシェーダファイルを …

【Unity】スプライト用のベタ塗り(単色)シェーダを導入する

はじめに この記事では上記のリポジトリに含まれている スプライト用のシェーダを導入する方法を紹介していきます 使用例 使い方 上記のシェーダファイルを Unity プロジェクトに追加します シェーダを使用したいオブジェクトのマテリアルの Shader を 「Spr…

【Unity】SpriteAtlas.GetSprite はスプライトの参照を返すのではなく複製するのでメモリに注意

概要 using UnityEngine; using UnityEngine.U2D; public class Example : MonoBehaviour { public SpriteAtlas m_atlas; private void Update() { m_atlas.GetSprite( "goal_01" ); } } 例えば上記のように Update 関数で毎フレーム SpriteAtlas.GetSprite …

【Unity】エディタ拡張でフォルダ(Mac なら Finder)を開く方法

概要 var path = @"D:\Hoge\Fuga"; EditorUtility.RevealInFinder( path ); EditorUtility.RevealInFinder を使用する

【Unity】スプライト用のアウトラインシェーダを導入する

はじめに この記事では上記のリポジトリに含まれている スプライト用のアウトラインシェーダを導入する方法を紹介していきます 使用例 使い方 上記のシェーダファイルを Unity プロジェクトに追加します シェーダを使用したいオブジェクトのマテリアルの Sha…

【Unity】MenuItem で絵文字を表示する

概要 [MenuItem( "Tools/⚙ Settings..." )] private static void Hoge() { } MenuItem に指定する文字列に絵文字を設定するだけで使用できる 使用できない絵文字や、Mac だと表示されるけど Windows 7 だと表示されない絵文字があるので注意

【Unity】iPhone X かどうかを確認する方法

概要 if ( iOS.DeviceGeneration.generation == DeviceGeneration.iPhoneX ) { } 参考サイト様

【Unity】セーフエリアを取得する方法

概要 var are = Screen.safeArea; 参考サイト様

【Unity】Unity 2018.2.7f1 で Android の IL2CPP ビルドしようとしたらエラーが発生して解決できなかった話

概要 Failed running C:\Program Files\Unity 2018.2.7f1\Editor\Data\il2cpp/build/il2cpp.exe --convert-to-cpp --emit-null-checks --enable-array-bounds-check --compile-cpp --libil2cpp-static --platform="Android" --architecture="ARMv7" --config…

【Unity】Android プラットフォームで Compression Method を「Default」にした場合と「LZ4」にした場合でアプリの起動時間にどれくらい差があるか

検証環境 Windows 7 Unity 2018.2.7f1 起動時間 Default:1.829 秒 LZ4:1.688 秒 参考サイト様

【Unity】アプリのビルドにかかった時間を調べる方法

概要 Unity の Console ウィンドウを右クリックして「Open Editor Log」を選択する もしくは C:\Users\【ユーザー名】\AppData\Local\Unity\Editor\Editor.log を開く 下記のようなテキストを検索する *** Completed 'Build.Player.AndroidPlayer' in 55 sec…

【Unity】Android プラットフォームで Internal ビルドした場合と Gradle ビルドした場合でビルド時間にどれくらい差があるか

検証環境 Windows 7 Unity 2018.2.7f1 ビルド時間 Internal:55 秒 Gradle:60 秒

【Unity】Your current multi-scene setup has inconsistent Lighting settings which may lead to different lighting when loading scenes individually or in a different order! Consider homogenizing the following:

概要 Your current multi-scene setup has inconsistent Lighting settings which may lead to different lighting when loading scenes individually or in a different order! Consider homogenizing the following: 1/2 scenes have different Realtime G…

【Unity】頂点カラーを変更するシェーダを導入する

はじめに http://www.shaderslab.com/demo-53---vertex-color-depending-id.html この記事では上記のサイト様が公開されている 頂点カラーを変更するシェーダを導入する方法を紹介していきます 使用例 使い方 上記のシェーダファイルを Unity プロジェクトに…

【Unity】コズミックシェーダを導入する

はじめに http://www.shaderslab.com/demo-34---cosmic-effect.html この記事では上記のサイト様が公開されている コズミックシェーダを導入する方法を紹介していきます 使用例 使い方 上記のシェーダファイルを Unity プロジェクトに追加します シェーダを…

【Unity】アウトライン付きのスクリーンスペーステクスチャシェーダを導入する

はじめに http://www.shaderslab.com/demo-95---flag-with-lighting.html この記事では上記のサイト様が公開されている アウトライン付きのスクリーンスペーステクスチャシェーダを 導入する方法を紹介していきます 使用例 適用前 適用後 使い方 上記のシェ…

【Unity】Unity 2018.3.0b1 新機能「Find references in scene」

概要 Scene に配置されているオブジェクトを選択して、 Inspector でコンポーネントを右クリックして「Find references in scene」を選択すると そのコンポーネントを参照しているオブジェクトを Hierarchy で検索することができます

【Unity】Unity 2018.3.0b1 から EditorWindow のタイトルに全角12文字入るようになった

概要 using UnityEditor; public class Hoge : EditorWindow { [MenuItem( "Tools/Hoge" )] private static void Open() { GetWindow<Hoge>( "ここに12文字まで入るみたいです" ); } }</hoge>

【Unity】Unity 2018.3.0b1 新機能「Start in fullscreen mode」

概要 Android プラットフォームの「PlayerSettings」に 「Start in fullscreen mode」が追加されました 「Start in fullscreen mode」がオン 「Start in fullscreen mode」がオフ