diff --git a/.claude/.gitignore b/.claude/.gitignore new file mode 100644 index 0000000..edb1527 --- /dev/null +++ b/.claude/.gitignore @@ -0,0 +1 @@ +settings.local.json \ No newline at end of file diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..d42a355 --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,133 @@ +{ + "env": { + "ENABLE_TOOL_SEARCH": "true", + "MCP_TIMEOUT": "5000", + "MCP_TOOL_TIMEOUT": "180000" + }, + "permissions": { + "allow": [ + "Bash(git add *)", + "Bash(git commit *)", + "Bash(git diff *)", + "Bash(git log *)", + "Bash(git remote *)", + "Bash(git mv *)", + "Bash(git rm *)", + "Bash(git status *)", + "Bash(git branch --show-current)", + "Bash(ls *)", + "Bash(mkdir *)", + "Bash(gh search code *)", + "Bash(gh api *)", + "Bash(gh issue *)", + "Bash(gh pr view *)", + "Bash(gh pr list *)", + "Bash(gh pr checks *)", + "Bash(rg *)", + "Bash(python3 --version)", + "Bash(node --version)", + "Bash(gradle *)", + "Bash(java *)", + "Bash(jar *)", + "Bash(unzip *)", + "Bash(javap *)", + "Bash(find *)", + "WebSearch", + "WebFetch(domain:github.com)", + "WebFetch(domain:raw.githubusercontent.com)", + "WebFetch(domain:docs.github.com)", + "WebFetch(domain:docs.unity3d.com)", + "WebFetch(domain:forum.unity.com)", + "WebFetch(domain:discussions.unity.com)", + "WebFetch(domain:issuetracker.unity3d.com)", + "WebFetch(domain:support.unity.com)", + "WebFetch(domain:unity.com)", + "WebFetch(domain:game.ci)", + "WebFetch(domain:api.github.com)", + "mcp__deepwiki__*", + "mcp__ide__getDiagnostics", + "mcp__jetbrains__*" + ], + "deny": [ + "Bash(sudo *)", + "Bash(su *)", + "Bash(rm *)", + "Bash(rm -r *)", + "Bash(rm -rf *)", + "Bash(rm -fr *)", + "Bash(rmdir *)", + "Bash(curl *)", + "Bash(wget *)", + "Bash(nc *)", + "Bash(npm publish *)", + "Bash(git branch -d *)", + "Bash(git branch -D *)", + "Bash(git branch --delete *)", + "Bash(git branch -m *)", + "Bash(git branch -M *)", + "Bash(git branch --move *)", + "Bash(git checkout *)", + "Bash(git commit --amend *)", + "Bash(git push -f *)", + "Bash(git reset *)", + "Bash(git rebase *)", + "Bash(git switch *)", + "Bash(psql *)", + "Bash(mysql *)", + "Bash(mongod *)", + "Bash(osascript *)", + "Bash(ssh *)", + "Bash(scp *)", + "Bash(ncat *)", + "Bash(telnet *)", + "Bash(open *)", + "Bash(security *)", + "Bash(pbcopy *)", + "Bash(pbpaste *)", + "Bash(* .env*)", + "Bash(* ~/.ssh/*)", + "Bash(* ~/.aws/*)", + "Bash(* ~/.config/gh/*)", + "Bash(* ~/.git-credentials)", + "Bash(* ~/.netrc)", + "Bash(* ~/.npmrc)", + "Read(./.env)", + "Edit(./.env)", + "Write(./.env)", + "Read(./.env.*)", + "Edit(./.env.*)", + "Write(./.env.*)", + "Read(./**/.env)", + "Read(./**/.env.*)", + "Read(/secrets/**)", + "Edit(/secrets/**)", + "Write(/secrets/**)", + "Read(~/.netrc)", + "Read(~/.npmrc)", + "Read(~/.ssh/**)", + "Read(~/.aws/**)", + "Read(~/.git-credentials)", + "Read(~/.config/gh/**)", + "Edit(~/.zshrc)", + "Write(~/.zshrc)", + "Edit(~/.bashrc)", + "Write(~/.bashrc)", + "Read(id_rsa)", + "Read(id_ed25519)", + "Read(**/*token*)", + "Read(**/*key*)", + "Read(!**/*monkey*)", + "Read(./Library/**)", + "Read(!./Library/PackageCache/**)", + "Write(**/packages-lock.json)", + "Write(*.meta)", + "mcp__jetbrains__build_solution", + "mcp__jetbrains__execute_terminal_command" + ], + "additionalDirectories": [] + }, + "enabledPlugins": { + "csharp-lsp@claude-plugins-official": true, + "unity-coding-skills@nowsprinting-unity-coding-skills": true + } +} diff --git a/Assets/APIExamples/Tests/Runtime/UnityTestFramework/MonoBehaviourTestExample.cs b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/MonoBehaviourTestExample.cs index f44a791..55f2ab0 100644 --- a/Assets/APIExamples/Tests/Runtime/UnityTestFramework/MonoBehaviourTestExample.cs +++ b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/MonoBehaviourTestExample.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2025 Koji Hasegawa. +// Copyright (c) 2021-2026 Koji Hasegawa. // This software is released under the MIT License. using System.Collections; @@ -6,8 +6,6 @@ using UnityEngine; using UnityEngine.TestTools; -#pragma warning disable CS0618 // Type or member is obsolete - namespace APIExamples.UnityTestFramework { /// @@ -40,7 +38,11 @@ private class SpyMyMonoBehaviour : MyMonoBehaviour, IMonoBehaviourTest yield return new MonoBehaviourTest(); // Verify +#if UNITY_2022_3_OR_NEWER + var spy = Object.FindAnyObjectByType(); +#else var spy = GameObject.FindObjectOfType(); +#endif Assert.That(spy.WasAwake, Is.True); Assert.That(spy.WasStart, Is.True); Assert.That(spy.WasDestroy, Is.False); @@ -87,7 +89,11 @@ public bool IsTestFinished // Teardown // Note: MockMyMonoBehaviour の実装ではこの時点で破棄済みですが、通常は後始末が必要です +#if UNITY_2022_3_OR_NEWER + var mock = Object.FindAnyObjectByType(); +#else var mock = GameObject.FindObjectOfType(); +#endif if (mock != null) { GameObject.DestroyImmediate(mock.gameObject); diff --git a/Assets/BasicExample/Tests/Editor/Validators/LevelValidator.cs b/Assets/BasicExample/Tests/Editor/Validators/LevelValidator.cs index b1831e0..cb41d03 100644 --- a/Assets/BasicExample/Tests/Editor/Validators/LevelValidator.cs +++ b/Assets/BasicExample/Tests/Editor/Validators/LevelValidator.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2025 Koji Hasegawa. +// Copyright (c) 2021-2026 Koji Hasegawa. // This software is released under the MIT License. using System.Collections.Generic; @@ -34,7 +34,13 @@ public class LevelValidator public void Levels下のSceneにSpawnPointが1つ設置されていること(string path) { EditorSceneManager.OpenScene(path); +#if UNITY_6000_4_OR_NEWER + var spawnPoints = Object.FindObjectsByType(); +#elif UNITY_2022_3_OR_NEWER + var spawnPoints = Object.FindObjectsByType(FindObjectsSortMode.None); +#else var spawnPoints = Object.FindObjectsOfType(); +#endif Assert.That(spawnPoints, Has.Length.EqualTo(1)); } @@ -43,7 +49,13 @@ public class LevelValidator public void Levels下のSceneにExitPointが設置されていること(string path) { EditorSceneManager.OpenScene(path); +#if UNITY_6000_4_OR_NEWER + var exitPoints = Object.FindObjectsByType(); +#elif UNITY_2022_3_OR_NEWER + var exitPoints = Object.FindObjectsByType(FindObjectsSortMode.None); +#else var exitPoints = Object.FindObjectsOfType(); +#endif Assert.That(exitPoints, Is.Not.Empty, "ExitPointは1つ以上設定されている"); diff --git a/Assets/Default.globalconfig b/Assets/Default.globalconfig new file mode 100644 index 0000000..c9f0c80 --- /dev/null +++ b/Assets/Default.globalconfig @@ -0,0 +1,2 @@ +is_global = true +dotnet_diagnostic.CS0618.severity = error \ No newline at end of file diff --git a/Assets/Default.globalconfig.meta b/Assets/Default.globalconfig.meta new file mode 100644 index 0000000..17bb7b5 --- /dev/null +++ b/Assets/Default.globalconfig.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 5ec5448e5ca8747fdb11066b4c23b174 +RoslynAnalyzerConfigImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/InputExample/Tests/Runtime/FirstPersonControllerLegacyTest.cs b/Assets/InputExample/Tests/Runtime/FirstPersonControllerLegacyTest.cs index 2424631..9c08920 100644 --- a/Assets/InputExample/Tests/Runtime/FirstPersonControllerLegacyTest.cs +++ b/Assets/InputExample/Tests/Runtime/FirstPersonControllerLegacyTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2023 Koji Hasegawa. +// Copyright (c) 2021-2026 Koji Hasegawa. // This software is released under the MIT License. using System; @@ -27,7 +27,11 @@ public class FirstPersonControllerLegacyTest public void SetUp() { // Note: LoadScene 属性は SetUp より先に処理されるため、ここで Scene はロード済み +#if UNITY_2022_3_OR_NEWER + _controller = UnityEngine.Object.FindAnyObjectByType(); +#else _controller = GameObject.FindObjectOfType(); +#endif } [Test] @@ -41,8 +45,8 @@ public void SetUp() var stub = new StubInputKey(); _controller.Input = stub; // テストスタブを注入 - stub.PushedKeys = new[] { KeyCode.W }; // Wキーを押す - await Task.Delay(500); // 0.5秒間保持 + stub.PushedKeys = new[] { KeyCode.W }; // Wキーを押す + await Task.Delay(500); // 0.5秒間保持 stub.PushedKeys = Array.Empty(); // 離す var afterPosition = _controller.transform.position; @@ -61,8 +65,8 @@ public void SetUp() _controller.Input = stub; // テストスタブを注入 stub.Axes = new[] { new SimulateAxis("Mouse X", 2.0f) }; // 右方向に移動 - await Task.Delay(500); // 0.5秒間保持 - stub.Axes = Array.Empty(); // 止める + await Task.Delay(500); // 0.5秒間保持 + stub.Axes = Array.Empty(); // 止める var afterRotation = _controller.transform.rotation; Assert.That(afterRotation, Is.EqualTo(Quaternion.Euler(0f, 45f, 0f)) diff --git a/Assets/InputSystemExample/Tests/Runtime/FirstPersonControllerTest.cs b/Assets/InputSystemExample/Tests/Runtime/FirstPersonControllerTest.cs index b2ce8fd..1ccae24 100644 --- a/Assets/InputSystemExample/Tests/Runtime/FirstPersonControllerTest.cs +++ b/Assets/InputSystemExample/Tests/Runtime/FirstPersonControllerTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2023 Koji Hasegawa. +// Copyright (c) 2021-2026 Koji Hasegawa. // This software is released under the MIT License. using System.Threading.Tasks; @@ -44,7 +44,11 @@ await EditorSceneManager.LoadSceneAsyncInPlayMode( new LoadSceneParameters(LoadSceneMode.Single)); // Note: Scenes in Buildに入れていないSceneなので、EditorSceneManagerでロード #endif +#if UNITY_2022_3_OR_NEWER + _controller = Object.FindAnyObjectByType(); +#else _controller = Object.FindObjectOfType(); +#endif } [TearDown] @@ -61,9 +65,9 @@ public void TearDown() .Using(new Vector3EqualityComparer(0.1f))); // 初期位置は原点 var keyboard = InputSystem.AddDevice(); // デバイス生成・追加 - _input.Press(keyboard.wKey); // Wキーを押す - await Task.Delay(500); // 0.5秒間保持 - _input.Release(keyboard.wKey); // 離す + _input.Press(keyboard.wKey); // Wキーを押す + await Task.Delay(500); // 0.5秒間保持 + _input.Release(keyboard.wKey); // 離す var afterPosition = _controller.transform.position; Assert.That(afterPosition, Is.EqualTo(new Vector3(0f, 0f, 4f)) @@ -78,8 +82,8 @@ public void TearDown() .Using(new Vector3EqualityComparer(0.1f))); // 初期位置は原点 var gamepad = InputSystem.AddDevice(); - _input.Set(gamepad.leftStick, Vector2.up); // 上方向に倒す - await Task.Delay(500); // 0.5秒間保持 + _input.Set(gamepad.leftStick, Vector2.up); // 上方向に倒す + await Task.Delay(500); // 0.5秒間保持 _input.Set(gamepad.leftStick, Vector2.zero); // 離す var afterPosition = _controller.transform.position; @@ -95,8 +99,8 @@ public void TearDown() var gamepad = InputSystem.AddDevice(); _input.Set(gamepad.rightStick, Vector2.right); // 右方向に倒す - await Task.Delay(500); // 0.5秒間保持 - _input.Set(gamepad.rightStick, Vector2.zero); // 離す + await Task.Delay(500); // 0.5秒間保持 + _input.Set(gamepad.rightStick, Vector2.zero); // 離す var afterRotation = _controller.transform.rotation; Assert.That(afterRotation, Is.EqualTo(Quaternion.Euler(0f, 45f, 0f)) diff --git a/Assets/InputSystemExample/Tests/Runtime/MonkeyTest.cs b/Assets/InputSystemExample/Tests/Runtime/MonkeyTest.cs index 615d85c..76bcb85 100644 --- a/Assets/InputSystemExample/Tests/Runtime/MonkeyTest.cs +++ b/Assets/InputSystemExample/Tests/Runtime/MonkeyTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2025 Koji Hasegawa. +// Copyright (c) 2021-2026 Koji Hasegawa. // This software is released under the MIT License. using System.Diagnostics.CodeAnalysis; @@ -53,7 +53,11 @@ public async Task MonkeyTesting() await SceneManager.LoadSceneAsync("InputSystemExample"); // Note: ランダム要素のあるSceneの場合、擬似乱数シードにrandom.Next()を使用すると再現に必要なシード値が1つで済んで便利です +#if UNITY_2022_3_OR_NEWER + var controller = Object.FindAnyObjectByType(); +#else var controller = Object.FindObjectOfType(); +#endif var lastLocation = controller.transform.position; var dontMoveCount = 0; diff --git a/Assets/InputSystemExample/Tests/Runtime/ScenarioTest.cs b/Assets/InputSystemExample/Tests/Runtime/ScenarioTest.cs index 748682f..bb2e7a9 100644 --- a/Assets/InputSystemExample/Tests/Runtime/ScenarioTest.cs +++ b/Assets/InputSystemExample/Tests/Runtime/ScenarioTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2023 Koji Hasegawa. +// Copyright (c) 2021-2026 Koji Hasegawa. // This software is released under the MIT License. using System.IO; @@ -61,7 +61,11 @@ public class ScenarioTest } } +#if UNITY_2022_3_OR_NEWER + var goalPlate = Object.FindAnyObjectByType(); +#else var goalPlate = Object.FindObjectOfType(); +#endif Assert.That(goalPlate.IsGoal, Is.True); } } diff --git a/Assets/SceneExample/Tests/Editor/EditorSceneManagerTest.cs b/Assets/SceneExample/Tests/Editor/EditorSceneManagerTest.cs index 546966f..7b88811f 100644 --- a/Assets/SceneExample/Tests/Editor/EditorSceneManagerTest.cs +++ b/Assets/SceneExample/Tests/Editor/EditorSceneManagerTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2025 Koji Hasegawa. +// Copyright (c) 2021-2026 Koji Hasegawa. // This software is released under the MIT License. using System.Linq; @@ -20,11 +20,19 @@ public class EditorSceneManagerTest var scene = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects); Assert.That(scene.rootCount, Is.EqualTo(2)); +#if UNITY_2022_3_OR_NEWER + var light = Object.FindAnyObjectByType(); +#else var light = Object.FindObjectOfType(); +#endif Assert.That(light.name, Is.EqualTo("Directional Light")); Assert.That(light.type, Is.EqualTo(LightType.Directional)); +#if UNITY_2022_3_OR_NEWER + var camera = Object.FindAnyObjectByType(); +#else var camera = Object.FindObjectOfType(); +#endif Assert.That(camera.name, Is.EqualTo("Main Camera")); } diff --git a/Assets/SceneExample/Tests/Runtime/NestedComponentTest.cs b/Assets/SceneExample/Tests/Runtime/NestedComponentTest.cs index 627ff4d..0182d78 100644 --- a/Assets/SceneExample/Tests/Runtime/NestedComponentTest.cs +++ b/Assets/SceneExample/Tests/Runtime/NestedComponentTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2025 Koji Hasegawa. +// Copyright (c) 2021-2026 Koji Hasegawa. // This software is released under the MIT License. using NUnit.Framework; @@ -23,7 +23,11 @@ public class NestedComponent : MonoBehaviour public void 入れ子のコンポーネントはAddComponentピッカーに表示されないがテストで使用できる() { var nestedComponent = new GameObject().AddComponent(); +#if UNITY_2022_3_OR_NEWER + var actual = Object.FindAnyObjectByType(); +#else var actual = Object.FindObjectOfType(); +#endif Assert.That(actual, Is.EqualTo(nestedComponent)); } diff --git a/LICENSE.md b/LICENSE.md index 61fa64f..0ed3582 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021-2025 Koji Hasegawa +Copyright (c) 2021-2026 Koji Hasegawa Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal