Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .claude/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
settings.local.json
133 changes: 133 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Copyright (c) 2021-2025 Koji Hasegawa.
// Copyright (c) 2021-2026 Koji Hasegawa.
// This software is released under the MIT License.

using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;

#pragma warning disable CS0618 // Type or member is obsolete

namespace APIExamples.UnityTestFramework
{
/// <summary>
Expand Down Expand Up @@ -40,7 +38,11 @@ public IEnumerator MonoBehaviourTestをテストスパイとして使用したMo
yield return new MonoBehaviourTest<SpyMyMonoBehaviour>();

// Verify
#if UNITY_2022_3_OR_NEWER
var spy = Object.FindAnyObjectByType<SpyMyMonoBehaviour>();
#else
var spy = GameObject.FindObjectOfType<SpyMyMonoBehaviour>();
#endif
Assert.That(spy.WasAwake, Is.True);
Assert.That(spy.WasStart, Is.True);
Assert.That(spy.WasDestroy, Is.False);
Expand Down Expand Up @@ -87,7 +89,11 @@ public IEnumerator MonoBehaviourTestをモックオブジェクトとして使

// Teardown
// Note: MockMyMonoBehaviour の実装ではこの時点で破棄済みですが、通常は後始末が必要です
#if UNITY_2022_3_OR_NEWER
var mock = Object.FindAnyObjectByType<MockMyMonoBehaviour>();
#else
var mock = GameObject.FindObjectOfType<MockMyMonoBehaviour>();
#endif
if (mock != null)
{
GameObject.DestroyImmediate(mock.gameObject);
Expand Down
14 changes: 13 additions & 1 deletion Assets/BasicExample/Tests/Editor/Validators/LevelValidator.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<SpawnPoint>();
#elif UNITY_2022_3_OR_NEWER
var spawnPoints = Object.FindObjectsByType<SpawnPoint>(FindObjectsSortMode.None);
#else
var spawnPoints = Object.FindObjectsOfType<SpawnPoint>();
#endif

Assert.That(spawnPoints, Has.Length.EqualTo(1));
}
Expand All @@ -43,7 +49,13 @@ public void Levels下のSceneにSpawnPointが1つ設置されていること(str
public void Levels下のSceneにExitPointが設置されていること(string path)
{
EditorSceneManager.OpenScene(path);
#if UNITY_6000_4_OR_NEWER
var exitPoints = Object.FindObjectsByType<ExitPoint>();
#elif UNITY_2022_3_OR_NEWER
var exitPoints = Object.FindObjectsByType<ExitPoint>(FindObjectsSortMode.None);
#else
var exitPoints = Object.FindObjectsOfType<ExitPoint>();
#endif

Assert.That(exitPoints, Is.Not.Empty, "ExitPointは1つ以上設定されている");

Expand Down
2 changes: 2 additions & 0 deletions Assets/Default.globalconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
is_global = true
dotnet_diagnostic.CS0618.severity = error
7 changes: 7 additions & 0 deletions Assets/Default.globalconfig.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -27,7 +27,11 @@ public class FirstPersonControllerLegacyTest
public void SetUp()
{
// Note: LoadScene 属性は SetUp より先に処理されるため、ここで Scene はロード済み
#if UNITY_2022_3_OR_NEWER
_controller = UnityEngine.Object.FindAnyObjectByType<FirstPersonControllerLegacy>();
#else
_controller = GameObject.FindObjectOfType<FirstPersonControllerLegacy>();
#endif
}

[Test]
Expand All @@ -41,8 +45,8 @@ public async Task Wキーで前方に移動()
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<KeyCode>(); // 離す

var afterPosition = _controller.transform.position;
Expand All @@ -61,8 +65,8 @@ public async Task マウス右移動で右方向を向く()
_controller.Input = stub; // テストスタブを注入

stub.Axes = new[] { new SimulateAxis("Mouse X", 2.0f) }; // 右方向に移動
await Task.Delay(500); // 0.5秒間保持
stub.Axes = Array.Empty<SimulateAxis>(); // 止める
await Task.Delay(500); // 0.5秒間保持
stub.Axes = Array.Empty<SimulateAxis>(); // 止める

var afterRotation = _controller.transform.rotation;
Assert.That(afterRotation, Is.EqualTo(Quaternion.Euler(0f, 45f, 0f))
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<FirstPersonController>();
#else
_controller = Object.FindObjectOfType<FirstPersonController>();
#endif
}

[TearDown]
Expand All @@ -61,9 +65,9 @@ public async Task Wキーで前方に移動()
.Using(new Vector3EqualityComparer(0.1f))); // 初期位置は原点

var keyboard = InputSystem.AddDevice<Keyboard>(); // デバイス生成・追加
_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))
Expand All @@ -78,8 +82,8 @@ public async Task 左スティックを上に倒すと前方に移動()
.Using(new Vector3EqualityComparer(0.1f))); // 初期位置は原点

var gamepad = InputSystem.AddDevice<Gamepad>();
_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;
Expand All @@ -95,8 +99,8 @@ public async Task 右スティックを右に倒すと右方向を向く()

var gamepad = InputSystem.AddDevice<Gamepad>();
_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))
Expand Down
6 changes: 5 additions & 1 deletion Assets/InputSystemExample/Tests/Runtime/MonkeyTest.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<FirstPersonController>();
#else
var controller = Object.FindObjectOfType<FirstPersonController>();
#endif
var lastLocation = controller.transform.position;
var dontMoveCount = 0;

Expand Down
6 changes: 5 additions & 1 deletion Assets/InputSystemExample/Tests/Runtime/ScenarioTest.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -61,7 +61,11 @@ public async Task PlaybackTesting_ゴールに到達すること(string path)
}
}

#if UNITY_2022_3_OR_NEWER
var goalPlate = Object.FindAnyObjectByType<GoalPlate>();
#else
var goalPlate = Object.FindObjectOfType<GoalPlate>();
#endif
Assert.That(goalPlate.IsGoal, Is.True);
}
}
Expand Down
10 changes: 9 additions & 1 deletion Assets/SceneExample/Tests/Editor/EditorSceneManagerTest.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -20,11 +20,19 @@ public void NewScene_withDefaultGameObjects_LightとCameraの設置されたScen
var scene = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
Assert.That(scene.rootCount, Is.EqualTo(2));

#if UNITY_2022_3_OR_NEWER
var light = Object.FindAnyObjectByType<Light>();
#else
var light = Object.FindObjectOfType<Light>();
#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<Camera>();
#else
var camera = Object.FindObjectOfType<Camera>();
#endif
Assert.That(camera.name, Is.EqualTo("Main Camera"));
}

Expand Down
6 changes: 5 additions & 1 deletion Assets/SceneExample/Tests/Runtime/NestedComponentTest.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -23,7 +23,11 @@ public class NestedComponent : MonoBehaviour
public void 入れ子のコンポーネントはAddComponentピッカーに表示されないがテストで使用できる()
{
var nestedComponent = new GameObject().AddComponent<NestedComponent>();
#if UNITY_2022_3_OR_NEWER
var actual = Object.FindAnyObjectByType<NestedComponent>();
#else
var actual = Object.FindObjectOfType<NestedComponent>();
#endif

Assert.That(actual, Is.EqualTo(nestedComponent));
}
Expand Down
Loading
Loading