RiderでCMakeプロジェクトを並列ビルドさせる
- RiderでCMakeプロジェクトを並列ビルドさせる
- 直接slnを書き換えるだけだと
cmake ..
のたびに設定が戻ってしまう - 以下のように対処
configボタンを押して
MSBuild global propertiesにMPを設定したらできた
UnityでSerializeFieldを再帰的にnull check
UnityでSerializeFieldを再帰的にnull check
public static void AssertNotNullSerializeFieldsRecursive( MonoBehaviour checking, string projectNameSpace, List<MonoBehaviour> checkedList) { #if UNITY_EDITOR bool isRoot = checkedList.Count == 0; var fields = checking.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance); checkedList.Add(checking); foreach (var field in fields) { if (field.GetCustomAttribute(typeof(SerializeField), true) == null) continue; var fieldValue = field.GetValue(checking); if (fieldValue == null || TryAccessGameObject(fieldValue) is UnassignedReferenceException) { Debug.LogError( $"<color=#76b900>{field.Name}</color> is null in <color=#76b900>{checking.name}</color>"); } var fieldType = field.FieldType; if (fieldType.Namespace == null) continue; if (fieldType.Namespace.StartsWith(projectNameSpace) == false) continue; if (fieldValue is MonoBehaviour fieldMonoBehaviour && checkedList.Contains(fieldMonoBehaviour) == false) AssertNotNullSerializeFieldsRecursive(fieldMonoBehaviour, projectNameSpace, checkedList); } if (isRoot) Debug.Log("done null check: " + checkedList.Count); #endif } public static Exception? TryAccessGameObject(object? fieldValue) { if (fieldValue is not GameObject fieldGameObject) return null; try { _ = fieldGameObject.activeSelf; } catch (Exception e) { return e; } return null; }
AudioClipとかのnullを検出できてない気がするのでまだ未完成
UnityでScriptableObjectを開くエディタ拡張
UnityでScriptableObjectを開くエディタ拡張
特定のウィンドウを開くには EditorApplication.ExecuteMenuItem(string)
を使うといい
public static void OpenScriptableObjectInspector(string assetPath) { // 指定されたScriptableObjectを取得 var scriptableObject = AssetDatabase.LoadAssetAtPath<ScriptableObject>(assetPath); if (scriptableObject == null) { Debug.LogError("The selected asset is not a ScriptableObject"); return; } // ScriptableObjectのインスペクタを表示する EditorUtility.FocusProjectWindow(); Selection.activeObject = scriptableObject; EditorApplication.ExecuteMenuItem("Window/General/Inspector"); }
UnityのPackageMangerで"Error when executing git command. fatal: not in a git directory"的なエラー
- UnityのPackageMangerで"Error when executing git command. fatal: not in a git directory"的なエラー
外付けSSDに入ってたプロジェクトで発生したが、ドライブを変えたら直った
Haskell/SDL2関連をWindowsでビルドする
Haskell/SDL2関連をWindowsでビルドする
2023年初頭あたりにビルドしたときのメモ
Haskellでsdl2単体を使うだけなら普通にビルドが通る
sdl2-mixerも同様に特に問題が起きなかったように思う (記憶がやや曖昧)
sdl2-image, sdl2-ttf, sdl2-gfx それぞれ別途対処が必要で時間がかかる
sdl2-image
プロジェクト stack.yamlのextra-depsをこうした
extra-deps: - git: https://github.com/haskell-game/sdl2-image.git commit: 382395c763b473032721c71921b5c9241142178f
sdl2-ttd, sdl2-gfx について
プロジェクトのstack.yamlにpackages追加
クローンしてきたリポジトリをプロジェクトに追加
packages: ... - ../libs/sdl2-ttf - ../libs/sdl2-gfx
それぞれのcabalに以下を追加
if os(windows) cpp-options: -D_SDL_main_h -DSDL_main_h_ -DSDL_MAIN_HANDLED
他にもエラーがあった気がしたので、いろいろ対処したと思う
DLLも実行フォルダに入れておくのを忘れないようにする