コガネブログ

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

2022-05-20から1日間の記事一覧

【Unity】Unity 2021 以降で配列の要素を範囲指定で取得する方法

概要 using UnityEngine; public class Example : MonoBehaviour { private void Awake() { var array = new[] { 0, 1, 2, 3, 4 }; // 1,2,3,4 foreach ( var value in array[ 1.. ] ) { Debug.Log( value ); } // 0,1,2,3 foreach ( var value in array[ ..…

【Unity】Preset の Excluded Properties を昇順に並べ替えるエディタ拡張

概要 Preset を右クリックして「Exclude all properties」を押すと プロパティが除外設定に登録されるが順番に規則性がないため 除外設定を解除したいプロパティを探すのが大変だった using System.Linq; using UnityEditor; using UnityEditor.Presets; pub…

【Unity】MenuItem( "CONTEXT/XXXX" ) を指定した関数がエディタで右クリックしても表示されない場合

概要 MenuItem( "CONTEXT/XXXX" ) を指定した関数が エディタで Inspector を右クリックしても表示されない現象に遭遇した using UnityEditor; using MenuCommand = System.ComponentModel.Design.MenuCommand; // ★ public static class PresetMenuItem { […

【Python】指定したフォルダ内のすべての .png のモードを RGB からインデックスに変更して背景色はピンクにするサンプル

ソースコード import glob from PIL import Image directory_path = "【フォルダのパス】/**/*.png" files = glob.glob(directory_path, recursive=True) for path in files: image = Image.open(path) image = image.convert("P") palette = image.getpalet…

【Unity】Assembly for Assembly Definition File 'XXXX.asmdef' will not be compiled,

概要 Assembly for Assembly Definition File 'XXXX.asmdef' will not be compiled, because it has no scripts associated with it. UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:TickCompilationPipeline (UnityEditor.Scripting.…

【Unity】エディタ拡張から Undo / Redo を実行する方法

概要 using UnityEditor; public static class Example { [MenuItem( "Tools/Undo" )] private static void RunUndo() { Undo.PerformUndo(); } [MenuItem( "Tools/Redo" )] private static void RunRedo() { Undo.PerformRedo(); } } Undo.PerformUndo() や…

【Python】指定したフォルダ内のすべての .png のモードを RGB からインデックスに変更するサンプル

ソースコード import glob from PIL import Image directory_path = "【フォルダのパス】/**/*.png" files = glob.glob(directory_path, recursive=True) for path in files: image = Image.open(path) image = image.convert("P") image.save(path)

【Python】PNG のモードを RGB からインデックスに変更するサンプル

ソースコード from PIL import Image path = "【.png のファイルパス】" image = Image.open(path) print(image.mode) image = image.convert("P") print(image.mode) image.save(path)

【Unity】Unable to parse XXXX.framework.js.br!

概要 Unable to parse XXXX.framework.js.br! If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported over HTTP connections. Migrate you…

【Unity】Please remove the CanvasRenderer component from the [XXXX] GameObject as this component is no longer necessary.

概要 Please remove the CanvasRenderer component from the [XXXX] GameObject as this component is no longer necessary. Unity プロジェクトのバージョンを上げたら ゲーム再生中に上記の警告が出力される現象に遭遇した 警告ログに記載されているゲーム…

【Unity】Prefab instance problem: XXXX (Missing Prefab with guid: YYYY)

概要 Prefab instance problem: XXXX (Missing Prefab with guid: YYYY) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) シーンを開いた時に上記のエラーが発生する現象に遭遇した 削除済みのプレハブから生成されたインスタンスが残っていたこと…

【Unity】Problem detected while opening the Scene file: 'XXXX'.

概要 Problem detected while opening the Scene file: 'XXXX'. Check the following logs for more details. シーンを開いた時に上記のエラーが発生する現象に遭遇した 削除済みのプレハブから生成されたインスタンスが残っていたことが原因だった このイン…