From 904f653a61ebaf09336d826c0f249207d370be1c Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Sat, 27 Dec 2025 23:04:20 +0900 Subject: [PATCH 01/11] Upgrade Unity version to 6000.0.43f1 --- .../copilot.data.migration.ask2agent.xml | 6 + .../Runtime/Input/PlayerInputActions.cs | 184 +++++++++++++++++- Packages/manifest.json | 14 +- Packages/packages-lock.json | 88 ++++----- ProjectSettings/MemorySettings.asset | 35 ++++ ProjectSettings/MultiplayerManager.asset | 7 + ProjectSettings/PackageManagerSettings.asset | 36 ++-- .../Settings.json | 2 - ProjectSettings/ProjectVersion.txt | 4 +- ProjectSettings/SceneTemplateSettings.json | 121 ++++++++++++ 10 files changed, 410 insertions(+), 87 deletions(-) create mode 100644 .idea/.idea.UnityTestExamples/.idea/copilot.data.migration.ask2agent.xml create mode 100644 ProjectSettings/MemorySettings.asset create mode 100644 ProjectSettings/MultiplayerManager.asset create mode 100644 ProjectSettings/SceneTemplateSettings.json diff --git a/.idea/.idea.UnityTestExamples/.idea/copilot.data.migration.ask2agent.xml b/.idea/.idea.UnityTestExamples/.idea/copilot.data.migration.ask2agent.xml new file mode 100644 index 0000000..1f2ea11 --- /dev/null +++ b/.idea/.idea.UnityTestExamples/.idea/copilot.data.migration.ask2agent.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/Assets/InputSystemExample/Scripts/Runtime/Input/PlayerInputActions.cs b/Assets/InputSystemExample/Scripts/Runtime/Input/PlayerInputActions.cs index e1fabae..f1872de 100644 --- a/Assets/InputSystemExample/Scripts/Runtime/Input/PlayerInputActions.cs +++ b/Assets/InputSystemExample/Scripts/Runtime/Input/PlayerInputActions.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator -// version 1.7.0 +// version 1.13.1 // from Assets/InputSystemExample/Scripts/Runtime/Input/PlayerInputActions.inputactions // // Changes to this file may cause incorrect behavior and will be lost if @@ -17,9 +17,73 @@ namespace InputSystemExample.Input { + /// + /// Provides programmatic access to , , and instances defined in asset "Assets/InputSystemExample/Scripts/Runtime/Input/PlayerInputActions.inputactions". + /// + /// + /// This class is source generated and any manual edits will be discarded if the associated asset is reimported or modified. + /// + /// + /// + /// using namespace UnityEngine; + /// using UnityEngine.InputSystem; + /// + /// // Example of using an InputActionMap named "Player" from a UnityEngine.MonoBehaviour implementing callback interface. + /// public class Example : MonoBehaviour, MyActions.IPlayerActions + /// { + /// private MyActions_Actions m_Actions; // Source code representation of asset. + /// private MyActions_Actions.PlayerActions m_Player; // Source code representation of action map. + /// + /// void Awake() + /// { + /// m_Actions = new MyActions_Actions(); // Create asset object. + /// m_Player = m_Actions.Player; // Extract action map object. + /// m_Player.AddCallbacks(this); // Register callback interface IPlayerActions. + /// } + /// + /// void OnDestroy() + /// { + /// m_Actions.Dispose(); // Destroy asset object. + /// } + /// + /// void OnEnable() + /// { + /// m_Player.Enable(); // Enable all actions within map. + /// } + /// + /// void OnDisable() + /// { + /// m_Player.Disable(); // Disable all actions within map. + /// } + /// + /// #region Interface implementation of MyActions.IPlayerActions + /// + /// // Invoked when "Move" action is either started, performed or canceled. + /// public void OnMove(InputAction.CallbackContext context) + /// { + /// Debug.Log($"OnMove: {context.ReadValue<Vector2>()}"); + /// } + /// + /// // Invoked when "Attack" action is either started, performed or canceled. + /// public void OnAttack(InputAction.CallbackContext context) + /// { + /// Debug.Log($"OnAttack: {context.ReadValue<float>()}"); + /// } + /// + /// #endregion + /// } + /// + /// public partial class @PlayerInputActions: IInputActionCollection2, IDisposable { + /// + /// Provides access to the underlying asset instance. + /// public InputActionAsset asset { get; } + + /// + /// Constructs a new instance. + /// public @PlayerInputActions() { asset = InputActionAsset.FromJson(@"{ @@ -285,57 +349,76 @@ public @PlayerInputActions() m_Player_Jump = m_Player.FindAction("Jump", throwIfNotFound: true); } + ~@PlayerInputActions() + { + UnityEngine.Debug.Assert(!m_Player.enabled, "This will cause a leak and performance issues, PlayerInputActions.Player.Disable() has not been called."); + } + + /// + /// Destroys this asset and all associated instances. + /// public void Dispose() { UnityEngine.Object.Destroy(asset); } + /// public InputBinding? bindingMask { get => asset.bindingMask; set => asset.bindingMask = value; } + /// public ReadOnlyArray? devices { get => asset.devices; set => asset.devices = value; } + /// public ReadOnlyArray controlSchemes => asset.controlSchemes; + /// public bool Contains(InputAction action) { return asset.Contains(action); } + /// public IEnumerator GetEnumerator() { return asset.GetEnumerator(); } + /// IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } + /// public void Enable() { asset.Enable(); } + /// public void Disable() { asset.Disable(); } + /// public IEnumerable bindings => asset.bindings; + /// public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false) { return asset.FindAction(actionNameOrId, throwIfNotFound); } + /// public int FindBinding(InputBinding bindingMask, out InputAction action) { return asset.FindBinding(bindingMask, out action); @@ -347,18 +430,51 @@ public int FindBinding(InputBinding bindingMask, out InputAction action) private readonly InputAction m_Player_Move; private readonly InputAction m_Player_Look; private readonly InputAction m_Player_Jump; + /// + /// Provides access to input actions defined in input action map "Player". + /// public struct PlayerActions { private @PlayerInputActions m_Wrapper; + + /// + /// Construct a new instance of the input action map wrapper class. + /// public PlayerActions(@PlayerInputActions wrapper) { m_Wrapper = wrapper; } + /// + /// Provides access to the underlying input action "Player/Move". + /// public InputAction @Move => m_Wrapper.m_Player_Move; + /// + /// Provides access to the underlying input action "Player/Look". + /// public InputAction @Look => m_Wrapper.m_Player_Look; + /// + /// Provides access to the underlying input action "Player/Jump". + /// public InputAction @Jump => m_Wrapper.m_Player_Jump; + /// + /// Provides access to the underlying input action map instance. + /// public InputActionMap Get() { return m_Wrapper.m_Player; } + /// public void Enable() { Get().Enable(); } + /// public void Disable() { Get().Disable(); } + /// public bool enabled => Get().enabled; + /// + /// Implicitly converts an to an instance. + /// public static implicit operator InputActionMap(PlayerActions set) { return set.Get(); } + /// + /// Adds , and callbacks provided via on all input actions contained in this map. + /// + /// Callback instance. + /// + /// If is null or have already been added this method does nothing. + /// + /// public void AddCallbacks(IPlayerActions instance) { if (instance == null || m_Wrapper.m_PlayerActionsCallbackInterfaces.Contains(instance)) return; @@ -374,6 +490,13 @@ public void AddCallbacks(IPlayerActions instance) @Jump.canceled += instance.OnJump; } + /// + /// Removes , and callbacks provided via on all input actions contained in this map. + /// + /// + /// Calling this method when have not previously been registered has no side-effects. + /// + /// private void UnregisterCallbacks(IPlayerActions instance) { @Move.started -= instance.OnMove; @@ -387,12 +510,25 @@ private void UnregisterCallbacks(IPlayerActions instance) @Jump.canceled -= instance.OnJump; } + /// + /// Unregisters and unregisters all input action callbacks via . + /// + /// public void RemoveCallbacks(IPlayerActions instance) { if (m_Wrapper.m_PlayerActionsCallbackInterfaces.Remove(instance)) UnregisterCallbacks(instance); } + /// + /// Replaces all existing callback instances and previously registered input action callbacks associated with them with callbacks provided via . + /// + /// + /// If is null, calling this method will only unregister all existing callbacks but not register any new callbacks. + /// + /// + /// + /// public void SetCallbacks(IPlayerActions instance) { foreach (var item in m_Wrapper.m_PlayerActionsCallbackInterfaces) @@ -401,8 +537,15 @@ public void SetCallbacks(IPlayerActions instance) AddCallbacks(instance); } } + /// + /// Provides a new instance referencing this action map. + /// public PlayerActions @Player => new PlayerActions(this); private int m_KeyboardMouseSchemeIndex = -1; + /// + /// Provides access to the input control scheme. + /// + /// public InputControlScheme KeyboardMouseScheme { get @@ -412,6 +555,10 @@ public InputControlScheme KeyboardMouseScheme } } private int m_GamepadSchemeIndex = -1; + /// + /// Provides access to the input control scheme. + /// + /// public InputControlScheme GamepadScheme { get @@ -421,6 +568,10 @@ public InputControlScheme GamepadScheme } } private int m_TouchSchemeIndex = -1; + /// + /// Provides access to the input control scheme. + /// + /// public InputControlScheme TouchScheme { get @@ -430,6 +581,10 @@ public InputControlScheme TouchScheme } } private int m_JoystickSchemeIndex = -1; + /// + /// Provides access to the input control scheme. + /// + /// public InputControlScheme JoystickScheme { get @@ -439,6 +594,10 @@ public InputControlScheme JoystickScheme } } private int m_XRSchemeIndex = -1; + /// + /// Provides access to the input control scheme. + /// + /// public InputControlScheme XRScheme { get @@ -447,10 +606,33 @@ public InputControlScheme XRScheme return asset.controlSchemes[m_XRSchemeIndex]; } } + /// + /// Interface to implement callback methods for all input action callbacks associated with input actions defined by "Player" which allows adding and removing callbacks. + /// + /// + /// public interface IPlayerActions { + /// + /// Method invoked when associated input action "Move" is either , or . + /// + /// + /// + /// void OnMove(InputAction.CallbackContext context); + /// + /// Method invoked when associated input action "Look" is either , or . + /// + /// + /// + /// void OnLook(InputAction.CallbackContext context); + /// + /// Method invoked when associated input action "Jump" is either , or . + /// + /// + /// + /// void OnJump(InputAction.CallbackContext context); } } diff --git a/Packages/manifest.json b/Packages/manifest.json index a93354f..7c52906 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -7,16 +7,18 @@ "com.nowsprinting.test-helper.input": "1.0.1", "com.nowsprinting.test-helper.random": "1.1.0", "com.nowsprinting.test-helper.ui": "1.1.3", - "com.unity.collab-proxy": "1.14.18", + "com.unity.ai.navigation": "2.0.6", + "com.unity.collab-proxy": "2.7.1", "com.unity.ide.rider": "3.0.34", "com.unity.ide.visualstudio": "2.0.22", - "com.unity.inputsystem": "1.7.0", + "com.unity.inputsystem": "1.13.1", + "com.unity.multiplayer.center": "1.0.0", "com.unity.test-framework": "1.4.6", - "com.unity.testtools.codecoverage": "1.2.4", - "com.unity.textmeshpro": "2.1.6", - "com.unity.timeline": "1.2.18", - "com.unity.ugui": "1.0.0", + "com.unity.testtools.codecoverage": "1.2.6", + "com.unity.timeline": "1.8.7", + "com.unity.ugui": "2.0.0", "net.tnrd.nsubstitute": "4.2.2", + "com.unity.modules.accessibility": "1.0.0", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", "com.unity.modules.animation": "1.0.0", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index d39fe08..0990ec2 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -61,43 +61,29 @@ }, "url": "https://package.openupm.com" }, - "com.unity.addressables": { - "version": "1.17.15", - "depth": 1, + "com.unity.ai.navigation": { + "version": "2.0.6", + "depth": 0, "source": "registry", "dependencies": { - "com.unity.modules.assetbundle": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0", - "com.unity.modules.imageconversion": "1.0.0", - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.scriptablebuildpipeline": "1.17.0", - "com.unity.modules.unitywebrequestassetbundle": "1.0.0" + "com.unity.modules.ai": "1.0.0" }, "url": "https://packages.unity.com" }, "com.unity.collab-proxy": { - "version": "1.14.18", + "version": "2.7.1", "depth": 0, "source": "registry", "dependencies": {}, "url": "https://packages.unity.com" }, "com.unity.ext.nunit": { - "version": "2.0.3", + "version": "2.0.5", "depth": 1, "source": "registry", "dependencies": {}, "url": "https://packages.unity.com" }, - "com.unity.external.test-protocol": { - "version": "1.0.0-preview", - "depth": 1, - "source": "registry", - "dependencies": { - "com.unity.nuget.newtonsoft-json": "2.0.0-preview" - }, - "url": "https://packages.unity.com" - }, "com.unity.ide.rider": { "version": "3.0.34", "depth": 0, @@ -117,7 +103,7 @@ "url": "https://packages.unity.com" }, "com.unity.inputsystem": { - "version": "1.7.0", + "version": "1.13.1", "depth": 0, "source": "registry", "dependencies": { @@ -125,34 +111,21 @@ }, "url": "https://packages.unity.com" }, - "com.unity.nuget.newtonsoft-json": { - "version": "2.0.0", - "depth": 1, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, - "com.unity.scriptablebuildpipeline": { - "version": "1.17.0", - "depth": 2, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" + "com.unity.multiplayer.center": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.uielements": "1.0.0" + } }, "com.unity.settings-manager": { - "version": "1.0.1", + "version": "2.0.1", "depth": 1, "source": "registry", "dependencies": {}, "url": "https://packages.unity.com" }, - "com.unity.subsystemregistration": { - "version": "1.0.6", - "depth": 2, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, "com.unity.test-framework": { "version": "1.4.6", "depth": 0, @@ -165,7 +138,7 @@ "url": "https://packages.unity.com" }, "com.unity.testtools.codecoverage": { - "version": "1.2.4", + "version": "1.2.6", "depth": 0, "source": "registry", "dependencies": { @@ -174,17 +147,8 @@ }, "url": "https://packages.unity.com" }, - "com.unity.textmeshpro": { - "version": "2.1.6", - "depth": 0, - "source": "registry", - "dependencies": { - "com.unity.ugui": "1.0.0" - }, - "url": "https://packages.unity.com" - }, "com.unity.timeline": { - "version": "1.2.18", + "version": "1.8.7", "depth": 0, "source": "registry", "dependencies": { @@ -196,7 +160,7 @@ "url": "https://packages.unity.com" }, "com.unity.ugui": { - "version": "1.0.0", + "version": "2.0.0", "depth": 0, "source": "builtin", "dependencies": { @@ -211,6 +175,12 @@ "dependencies": {}, "url": "https://package.openupm.com" }, + "com.unity.modules.accessibility": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, "com.unity.modules.ai": { "version": "1.0.0", "depth": 0, @@ -258,6 +228,12 @@ "com.unity.modules.animation": "1.0.0" } }, + "com.unity.modules.hierarchycore": { + "version": "1.0.0", + "depth": 1, + "source": "builtin", + "dependencies": {} + }, "com.unity.modules.imageconversion": { "version": "1.0.0", "depth": 0, @@ -344,8 +320,10 @@ "depth": 0, "source": "builtin", "dependencies": { + "com.unity.modules.ui": "1.0.0", "com.unity.modules.imgui": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0" + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.hierarchycore": "1.0.0" } }, "com.unity.modules.umbra": { diff --git a/ProjectSettings/MemorySettings.asset b/ProjectSettings/MemorySettings.asset new file mode 100644 index 0000000..5b5face --- /dev/null +++ b/ProjectSettings/MemorySettings.asset @@ -0,0 +1,35 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!387306366 &1 +MemorySettings: + m_ObjectHideFlags: 0 + m_EditorMemorySettings: + m_MainAllocatorBlockSize: -1 + m_ThreadAllocatorBlockSize: -1 + m_MainGfxBlockSize: -1 + m_ThreadGfxBlockSize: -1 + m_CacheBlockSize: -1 + m_TypetreeBlockSize: -1 + m_ProfilerBlockSize: -1 + m_ProfilerEditorBlockSize: -1 + m_BucketAllocatorGranularity: -1 + m_BucketAllocatorBucketsCount: -1 + m_BucketAllocatorBlockSize: -1 + m_BucketAllocatorBlockCount: -1 + m_ProfilerBucketAllocatorGranularity: -1 + m_ProfilerBucketAllocatorBucketsCount: -1 + m_ProfilerBucketAllocatorBlockSize: -1 + m_ProfilerBucketAllocatorBlockCount: -1 + m_TempAllocatorSizeMain: -1 + m_JobTempAllocatorBlockSize: -1 + m_BackgroundJobTempAllocatorBlockSize: -1 + m_JobTempAllocatorReducedBlockSize: -1 + m_TempAllocatorSizeGIBakingWorker: -1 + m_TempAllocatorSizeNavMeshWorker: -1 + m_TempAllocatorSizeAudioWorker: -1 + m_TempAllocatorSizeCloudWorker: -1 + m_TempAllocatorSizeGfx: -1 + m_TempAllocatorSizeJobWorker: -1 + m_TempAllocatorSizeBackgroundWorker: -1 + m_TempAllocatorSizePreloadManager: -1 + m_PlatformMemorySettings: {} diff --git a/ProjectSettings/MultiplayerManager.asset b/ProjectSettings/MultiplayerManager.asset new file mode 100644 index 0000000..2a93664 --- /dev/null +++ b/ProjectSettings/MultiplayerManager.asset @@ -0,0 +1,7 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!655991488 &1 +MultiplayerManager: + m_ObjectHideFlags: 0 + m_EnableMultiplayerRoles: 0 + m_StrippingTypes: {} diff --git a/ProjectSettings/PackageManagerSettings.asset b/ProjectSettings/PackageManagerSettings.asset index abe1834..2985b52 100644 --- a/ProjectSettings/PackageManagerSettings.asset +++ b/ProjectSettings/PackageManagerSettings.asset @@ -12,15 +12,22 @@ MonoBehaviour: m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} m_Name: m_EditorClassIdentifier: + m_EnablePreReleasePackages: 0 + m_AdvancedSettingsExpanded: 1 m_ScopedRegistriesSettingsExpanded: 1 + m_SeeAllPackageVersions: 0 + m_DismissPreviewPackagesInUse: 0 oneTimeWarningShown: 0 + oneTimeDeprecatedPopUpShown: 0 m_Registries: - m_Id: main m_Name: m_Url: https://packages.unity.com m_Scopes: [] m_IsDefault: 1 - - m_Id: scoped:package.openupm.com + m_Capabilities: 7 + m_ConfigSource: 0 + - m_Id: scoped:project:package.openupm.com m_Name: package.openupm.com m_Url: https://package.openupm.com m_Scopes: @@ -29,26 +36,13 @@ MonoBehaviour: - com.openupm - net.tnrd.nsubstitute m_IsDefault: 0 - m_UserSelectedRegistryName: + m_Capabilities: 0 + m_ConfigSource: 4 + m_UserSelectedRegistryName: package.openupm.com m_UserAddingNewScopedRegistry: 0 m_RegistryInfoDraft: - m_ErrorMessage: - m_Original: - m_Id: scoped:package.openupm.com - m_Name: package.openupm.com - m_Url: https://package.openupm.com - m_Scopes: - - com.cysharp - - com.nowsprinting - - com.openupm - - net.tnrd.nsubstitute - m_IsDefault: 0 m_Modified: 0 - m_Name: package.openupm.com - m_Url: https://package.openupm.com - m_Scopes: - - com.cysharp - - com.nowsprinting - - com.openupm - - net.tnrd.nsubstitute - m_SelectedScopeIndex: 0 + m_ErrorMessage: + m_UserModificationsInstanceId: -888 + m_OriginalInstanceId: -892 + m_LoadAssets: 0 diff --git a/ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json b/ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json index ad11087..3c7b4c1 100644 --- a/ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json +++ b/ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json @@ -1,6 +1,4 @@ { - "m_Name": "Settings", - "m_Path": "ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json", "m_Dictionary": { "m_DictionaryValues": [] } diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 4c19129..355f111 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2019.4.40f1 -m_EditorVersionWithRevision: 2019.4.40f1 (ffc62b691db5) +m_EditorVersion: 6000.0.43f1 +m_EditorVersionWithRevision: 6000.0.43f1 (97272b72f107) diff --git a/ProjectSettings/SceneTemplateSettings.json b/ProjectSettings/SceneTemplateSettings.json new file mode 100644 index 0000000..ede5887 --- /dev/null +++ b/ProjectSettings/SceneTemplateSettings.json @@ -0,0 +1,121 @@ +{ + "templatePinStates": [], + "dependencyTypeInfos": [ + { + "userAdded": false, + "type": "UnityEngine.AnimationClip", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.Animations.AnimatorController", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.AnimatorOverrideController", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.Audio.AudioMixerController", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.ComputeShader", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.Cubemap", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.GameObject", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.LightingDataAsset", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.LightingSettings", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Material", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.MonoScript", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.PhysicsMaterial", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.PhysicsMaterial2D", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.VolumeProfile", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.SceneAsset", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.Shader", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.ShaderVariantCollection", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.Texture", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Texture2D", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Timeline.TimelineAsset", + "defaultInstantiationMode": 0 + } + ], + "defaultDependencyTypeInfo": { + "userAdded": false, + "type": "", + "defaultInstantiationMode": 1 + }, + "newSceneOverride": 0 +} \ No newline at end of file From 273196e378b0a8d81c4445cbeb1bd2dc222e6315 Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Sun, 5 Oct 2025 00:08:24 +0900 Subject: [PATCH 02/11] Fix Unity versions used to run tests on CI --- .github/workflows/test-integration.yml | 4 ---- .github/workflows/test.yml | 4 ---- 2 files changed, 8 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 77169fc..cdc6746 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -40,10 +40,6 @@ jobs: fail-fast: false matrix: unityVersion: # Available versions see: https://game.ci/docs/docker/versions - - 2019.4.40f1 - - 2020.3.49f1 - - 2021.3.45f1 - - 2022.3.62f1 - 6000.0.43f1 - 6000.0.44f1 # pin test-framework v1.5.1 - 6000.0.59f2 # pin test-framework v1.6.0 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5c6f188..30e6224 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,10 +41,6 @@ jobs: fail-fast: false matrix: unityVersion: # Available versions see: https://game.ci/docs/docker/versions - - 2019.4.40f1 - - 2020.3.49f1 - - 2021.3.45f1 - - 2022.3.62f1 - 6000.0.43f1 - 6000.0.44f1 # pin test-framework v1.5.1 - 6000.0.59f2 # pin test-framework v1.6.0 From 561e3cfd1e5dfbdb853aee95dc823eced67ce31c Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Sun, 5 Oct 2025 00:37:51 +0900 Subject: [PATCH 03/11] Remove suppress C#8.0+ syntax sugar (for under Unity 2020.2 compatibility) --- .editorconfig | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.editorconfig b/.editorconfig index a50a818..b2ccab7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -267,13 +267,6 @@ resharper_switch_statement_handles_some_known_enum_values_with_default_highlight # BannedApiAnalyzers dotnet_diagnostic.RS0030.severity = error -# Suppress C#8.0+ syntax sugar (for under Unity 2020.2 compatibility) -# See: https://www.jetbrains.com/help/resharper/Reference__Code_Inspections_CSHARP.html -resharper_convert_to_using_declaration_highlighting = none -resharper_convert_to_null_coalescing_compound_assignment_highlighting = none -resharper_merge_into_logical_pattern_highlighting = none -resharper_use_negated_pattern_in_is_expression_highlighting = none - # Test codes for Unity Test Framework [**/Tests/**/*.cs] From 56cfea73cfe0e69bf394530763659f0783e23619 Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Mon, 11 Aug 2025 07:10:22 +0900 Subject: [PATCH 04/11] Uninstall net.tnrd.nsubstitute package --- .../Tests/Runtime/TestDoubleExample.Tests.asmdef | 5 +---- Packages/manifest.json | 5 +---- Packages/packages-lock.json | 7 ------- ProjectSettings/PackageManagerSettings.asset | 2 -- 4 files changed, 2 insertions(+), 17 deletions(-) diff --git a/Assets/TestDoubleExample/Tests/Runtime/TestDoubleExample.Tests.asmdef b/Assets/TestDoubleExample/Tests/Runtime/TestDoubleExample.Tests.asmdef index 2ba2425..f4163ad 100644 --- a/Assets/TestDoubleExample/Tests/Runtime/TestDoubleExample.Tests.asmdef +++ b/Assets/TestDoubleExample/Tests/Runtime/TestDoubleExample.Tests.asmdef @@ -11,10 +11,7 @@ "allowUnsafeCode": false, "overrideReferences": true, "precompiledReferences": [ - "nunit.framework.dll", - "NSubstitute.dll", - "Castle.Core.dll", - "System.Threading.Tasks.Extensions.dll" + "nunit.framework.dll" ], "autoReferenced": false, "defineConstraints": [ diff --git a/Packages/manifest.json b/Packages/manifest.json index 7c52906..76773e5 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -17,7 +17,6 @@ "com.unity.testtools.codecoverage": "1.2.6", "com.unity.timeline": "1.8.7", "com.unity.ugui": "2.0.0", - "net.tnrd.nsubstitute": "4.2.2", "com.unity.modules.accessibility": "1.0.0", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", @@ -60,9 +59,7 @@ "url": "https://package.openupm.com", "scopes": [ "com.cysharp", - "com.nowsprinting", - "com.openupm", - "net.tnrd.nsubstitute" + "com.nowsprinting" ] } ] diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 0990ec2..2375417 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -168,13 +168,6 @@ "com.unity.modules.imgui": "1.0.0" } }, - "net.tnrd.nsubstitute": { - "version": "4.2.2", - "depth": 0, - "source": "registry", - "dependencies": {}, - "url": "https://package.openupm.com" - }, "com.unity.modules.accessibility": { "version": "1.0.0", "depth": 0, diff --git a/ProjectSettings/PackageManagerSettings.asset b/ProjectSettings/PackageManagerSettings.asset index 2985b52..4528654 100644 --- a/ProjectSettings/PackageManagerSettings.asset +++ b/ProjectSettings/PackageManagerSettings.asset @@ -33,8 +33,6 @@ MonoBehaviour: m_Scopes: - com.cysharp - com.nowsprinting - - com.openupm - - net.tnrd.nsubstitute m_IsDefault: 0 m_Capabilities: 0 m_ConfigSource: 4 From d72a228074c8bf83b23871528b91569aa0f5e570 Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Mon, 11 Aug 2025 07:23:07 +0900 Subject: [PATCH 05/11] Add UnityNuGet registry settings --- Packages/manifest.json | 14 +++++++++++--- ProjectSettings/PackageManagerSettings.asset | 16 ++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Packages/manifest.json b/Packages/manifest.json index 76773e5..af57420 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -55,12 +55,20 @@ ], "scopedRegistries": [ { - "name": "package.openupm.com", + "name": "OpenUPM", "url": "https://package.openupm.com", "scopes": [ - "com.cysharp", - "com.nowsprinting" + "com.nowsprinting", + "com.cysharp" ] + }, + { + "name": "UnityNuGet", + "url": "https://package.openupm.com", + "scopes": [ + "org.nuget" + ], + "overrideBuiltIns": true } ] } diff --git a/ProjectSettings/PackageManagerSettings.asset b/ProjectSettings/PackageManagerSettings.asset index 4528654..e568051 100644 --- a/ProjectSettings/PackageManagerSettings.asset +++ b/ProjectSettings/PackageManagerSettings.asset @@ -27,16 +27,24 @@ MonoBehaviour: m_IsDefault: 1 m_Capabilities: 7 m_ConfigSource: 0 - - m_Id: scoped:project:package.openupm.com - m_Name: package.openupm.com + - m_Id: scoped:project:OpenUPM + m_Name: OpenUPM m_Url: https://package.openupm.com m_Scopes: - - com.cysharp - com.nowsprinting + - com.cysharp + m_IsDefault: 0 + m_Capabilities: 0 + m_ConfigSource: 4 + - m_Id: scoped:project:UnityNuGet + m_Name: UnityNuGet + m_Url: https://package.openupm.com + m_Scopes: + - org.nuget m_IsDefault: 0 m_Capabilities: 0 m_ConfigSource: 4 - m_UserSelectedRegistryName: package.openupm.com + m_UserSelectedRegistryName: OpenUPM m_UserAddingNewScopedRegistry: 0 m_RegistryInfoDraft: m_Modified: 0 From 32d240ba6cddf2bf1452a68f2b3f1bd05e0b7773 Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Mon, 11 Aug 2025 07:23:34 +0900 Subject: [PATCH 06/11] Install NSubstitute NuGet package v5.3.0 --- .../Runtime/TestDoubleExample.Tests.asmdef | 6 +- Packages/manifest.json | 2 + Packages/packages-lock.json | 66 +++++++++++++++++++ 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/Assets/TestDoubleExample/Tests/Runtime/TestDoubleExample.Tests.asmdef b/Assets/TestDoubleExample/Tests/Runtime/TestDoubleExample.Tests.asmdef index f4163ad..1392188 100644 --- a/Assets/TestDoubleExample/Tests/Runtime/TestDoubleExample.Tests.asmdef +++ b/Assets/TestDoubleExample/Tests/Runtime/TestDoubleExample.Tests.asmdef @@ -4,14 +4,16 @@ "references": [ "UnityEngine.TestRunner", "UnityEditor.TestRunner", - "TestDoubleExample" + "TestDoubleExample", + "NSubstitute.Analyzers.CSharp_Unity" ], "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false, "overrideReferences": true, "precompiledReferences": [ - "nunit.framework.dll" + "nunit.framework.dll", + "NSubstitute.dll" ], "autoReferenced": false, "defineConstraints": [ diff --git a/Packages/manifest.json b/Packages/manifest.json index af57420..baf2f65 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -17,6 +17,8 @@ "com.unity.testtools.codecoverage": "1.2.6", "com.unity.timeline": "1.8.7", "com.unity.ugui": "2.0.0", + "org.nuget.nsubstitute": "5.3.0", + "org.nuget.nsubstitute.analyzers.csharp": "1.0.17", "com.unity.modules.accessibility": "1.0.0", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 2375417..5525ef4 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -168,6 +168,72 @@ "com.unity.modules.imgui": "1.0.0" } }, + "org.nuget.castle.core": { + "version": "5.1.1", + "depth": 1, + "source": "registry", + "dependencies": { + "org.nuget.system.diagnostics.eventlog": "4.7.0", + "org.nuget.system.reflection.emit": "4.7.0" + }, + "url": "https://package.openupm.com" + }, + "org.nuget.nsubstitute": { + "version": "5.3.0", + "depth": 0, + "source": "registry", + "dependencies": { + "org.nuget.castle.core": "5.1.1", + "org.nuget.system.threading.tasks.extensions": "4.4.0" + }, + "url": "https://package.openupm.com" + }, + "org.nuget.nsubstitute.analyzers.csharp": { + "version": "1.0.17", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://package.openupm.com" + }, + "org.nuget.system.diagnostics.eventlog": { + "version": "4.7.0", + "depth": 2, + "source": "registry", + "dependencies": { + "org.nuget.system.security.principal.windows": "4.7.0" + }, + "url": "https://package.openupm.com" + }, + "org.nuget.system.reflection.emit": { + "version": "4.7.0", + "depth": 2, + "source": "registry", + "dependencies": { + "org.nuget.system.reflection.emit.ilgeneration": "4.7.0" + }, + "url": "https://package.openupm.com" + }, + "org.nuget.system.reflection.emit.ilgeneration": { + "version": "4.7.0", + "depth": 3, + "source": "registry", + "dependencies": {}, + "url": "https://package.openupm.com" + }, + "org.nuget.system.security.principal.windows": { + "version": "4.7.0", + "depth": 3, + "source": "registry", + "dependencies": {}, + "url": "https://package.openupm.com" + }, + "org.nuget.system.threading.tasks.extensions": { + "version": "4.4.0", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://package.openupm.com" + }, "com.unity.modules.accessibility": { "version": "1.0.0", "depth": 0, From 7b549ea2460c04ee355386d996bfce277e44e9a7 Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Wed, 5 Nov 2025 01:15:04 +0900 Subject: [PATCH 07/11] Add version defines --- .../Editor/APIExamples.Editor.Tests.asmdef | 20 ++++++++++++++----- .../Tests/Runtime/APIExamples.Tests.asmdef | 17 +++++++++++++--- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Assets/APIExamples/Tests/Editor/APIExamples.Editor.Tests.asmdef b/Assets/APIExamples/Tests/Editor/APIExamples.Editor.Tests.asmdef index 3e283a5..bd148d2 100644 --- a/Assets/APIExamples/Tests/Editor/APIExamples.Editor.Tests.asmdef +++ b/Assets/APIExamples/Tests/Editor/APIExamples.Editor.Tests.asmdef @@ -4,10 +4,9 @@ "references": [ "UnityEngine.TestRunner", "UnityEditor.TestRunner", - "NUnit.Analyzers_Unity", - "APIExamples.Tests", - "UniTask", - "TestHelper" + "APIExamples.Tests", + "UniTask", + "TestHelper" ], "includePlatforms": [ "Editor" @@ -22,6 +21,17 @@ "defineConstraints": [ "UNITY_INCLUDE_TESTS" ], - "versionDefines": [], + "versionDefines": [ + { + "name": "com.unity.test-framework", + "expression": "1.5", + "define": "ENABLE_UTF_1_5" + }, + { + "name": "com.unity.test-framework", + "expression": "1.6", + "define": "ENABLE_UTF_1_6" + } + ], "noEngineReferences": false } \ No newline at end of file diff --git a/Assets/APIExamples/Tests/Runtime/APIExamples.Tests.asmdef b/Assets/APIExamples/Tests/Runtime/APIExamples.Tests.asmdef index eefcc21..fac6e79 100644 --- a/Assets/APIExamples/Tests/Runtime/APIExamples.Tests.asmdef +++ b/Assets/APIExamples/Tests/Runtime/APIExamples.Tests.asmdef @@ -5,8 +5,8 @@ "UnityEngine.TestRunner", "UnityEditor.TestRunner", "APIExamples", - "UniTask", - "TestHelper" + "UniTask", + "TestHelper" ], "includePlatforms": [], "excludePlatforms": [], @@ -19,6 +19,17 @@ "defineConstraints": [ "UNITY_INCLUDE_TESTS" ], - "versionDefines": [], + "versionDefines": [ + { + "name": "com.unity.test-framework", + "expression": "1.5", + "define": "ENABLE_UTF_1_5" + }, + { + "name": "com.unity.test-framework", + "expression": "1.6", + "define": "ENABLE_UTF_1_6" + } + ], "noEngineReferences": false } \ No newline at end of file From 566c23969ba882b2a70d6dd673823e7e570ebbf9 Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Fri, 7 Nov 2025 07:08:37 +0900 Subject: [PATCH 08/11] Add UnityOneTimeSetUp and TearDown attribute examples (UTF 1.5+) --- .../UnityOneTimeSetupAttributeExample.cs | 73 +++++++++++++++++ .../UnityOneTimeSetupAttributeExample.cs.meta | 3 + .../UnityOneTimeTearDownAttributeExample.cs | 76 ++++++++++++++++++ ...ityOneTimeTearDownAttributeExample.cs.meta | 3 + .../UnityOneTimeSetupAttributeExample.cs | 75 ++++++++++++++++++ .../UnityOneTimeSetupAttributeExample.cs.meta | 3 + .../UnityOneTimeTearDownAttributeExample.cs | 78 +++++++++++++++++++ ...ityOneTimeTearDownAttributeExample.cs.meta | 3 + 8 files changed, 314 insertions(+) create mode 100644 Assets/APIExamples/Tests/Editor/UnityTestFramework/UnityOneTimeSetupAttributeExample.cs create mode 100644 Assets/APIExamples/Tests/Editor/UnityTestFramework/UnityOneTimeSetupAttributeExample.cs.meta create mode 100644 Assets/APIExamples/Tests/Editor/UnityTestFramework/UnityOneTimeTearDownAttributeExample.cs create mode 100644 Assets/APIExamples/Tests/Editor/UnityTestFramework/UnityOneTimeTearDownAttributeExample.cs.meta create mode 100644 Assets/APIExamples/Tests/Runtime/UnityTestFramework/UnityOneTimeSetupAttributeExample.cs create mode 100644 Assets/APIExamples/Tests/Runtime/UnityTestFramework/UnityOneTimeSetupAttributeExample.cs.meta create mode 100644 Assets/APIExamples/Tests/Runtime/UnityTestFramework/UnityOneTimeTearDownAttributeExample.cs create mode 100644 Assets/APIExamples/Tests/Runtime/UnityTestFramework/UnityOneTimeTearDownAttributeExample.cs.meta diff --git a/Assets/APIExamples/Tests/Editor/UnityTestFramework/UnityOneTimeSetupAttributeExample.cs b/Assets/APIExamples/Tests/Editor/UnityTestFramework/UnityOneTimeSetupAttributeExample.cs new file mode 100644 index 0000000..ada2be4 --- /dev/null +++ b/Assets/APIExamples/Tests/Editor/UnityTestFramework/UnityOneTimeSetupAttributeExample.cs @@ -0,0 +1,73 @@ +// Copyright (c) 2021-2025 Koji Hasegawa. +// This software is released under the MIT License. + +#if ENABLE_UTF_1_5 +using System.Collections; +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; +using APIExamples.NUnit; +using NUnit.Framework; +using UnityEngine.TestTools; +using Is = APIExamples.NUnit.Is; + +namespace APIExamples.Editor.UnityTestFramework +{ + /// + /// の使用例 + /// + /// + /// Required: Unity Test Framework v1.5 or later + /// + /// + /// + [TestFixture] + [SuppressMessage("ReSharper", "AccessToStaticMemberViaDerivedType")] + public class UnityOneTimeSetupAttributeExample + { + private int _oneTimeSetupCount; + private int _setupCount; + + /// + /// テストクラス内の最初のテストの実行前に一度だけ実行されます + /// + [UnityOneTimeSetUp] + public IEnumerator OneTimeSetUp() + { + yield return null; + _oneTimeSetupCount++; + } + + /// + /// 各テストメソッドの前に実行されます + /// + [SetUp] + public void SetUp() + { + _setupCount++; + } + + [Test, Order(0)] + public void TestMethod() + { + Assert.That(_oneTimeSetupCount, Is.EqualTo(1), "OneTimeSetUpはTestFixtureごとに一度だけ実行される"); + Assert.That(_setupCount, Is.EqualTo(1), "最初のテストなのでSetUpは1回実行されている"); + } + + [Test, Order(1)] + public async Task TestMethodAsync() + { + await Task.Yield(); + Assert.That(_oneTimeSetupCount, Is.EqualTo(1), "OneTimeSetUpはTestFixtureごとに一度だけ実行される"); + Assert.That(_setupCount, Is.EqualTo(2), "2番目のテストなのでSetUpは2回実行されている"); + } + + [UnityTest, Order(2)] + public IEnumerator UnityTestMethod() + { + yield return null; + Assert.That(_oneTimeSetupCount, Is.EqualTo(1), "OneTimeSetUpはTestFixtureごとに一度だけ実行される"); + Assert.That(_setupCount, Is.EqualTo(3), "3番目のテストなのでSetUpは3回実行されている"); + } + } +} +#endif diff --git a/Assets/APIExamples/Tests/Editor/UnityTestFramework/UnityOneTimeSetupAttributeExample.cs.meta b/Assets/APIExamples/Tests/Editor/UnityTestFramework/UnityOneTimeSetupAttributeExample.cs.meta new file mode 100644 index 0000000..7f9627c --- /dev/null +++ b/Assets/APIExamples/Tests/Editor/UnityTestFramework/UnityOneTimeSetupAttributeExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: dc4b105e00624aac8b90c524c27db1c7 +timeCreated: 1762467282 \ No newline at end of file diff --git a/Assets/APIExamples/Tests/Editor/UnityTestFramework/UnityOneTimeTearDownAttributeExample.cs b/Assets/APIExamples/Tests/Editor/UnityTestFramework/UnityOneTimeTearDownAttributeExample.cs new file mode 100644 index 0000000..35eb39f --- /dev/null +++ b/Assets/APIExamples/Tests/Editor/UnityTestFramework/UnityOneTimeTearDownAttributeExample.cs @@ -0,0 +1,76 @@ +// Copyright (c) 2021-2025 Koji Hasegawa. +// This software is released under the MIT License. + +#if ENABLE_UTF_1_5 +using System.Collections; +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; +using APIExamples.NUnit; +using NUnit.Framework; +using UnityEngine; +using UnityEngine.TestTools; +using Is = APIExamples.NUnit.Is; + +namespace APIExamples.Editor.UnityTestFramework +{ + /// + /// の使用例 + /// + /// + /// Required: Unity Test Framework v1.5 or later + /// + /// + /// + [TestFixture] + [SuppressMessage("ReSharper", "AccessToStaticMemberViaDerivedType")] + public class UnityOneTimeTearDownAttributeExample + { + private int _oneTimeTeardownCount; + private int _teardownCount; + + /// + /// クラス内の最後のテストの実行後に一度だけ実行されます + /// + [UnityOneTimeTearDown] + public IEnumerator OneTimeTearDown() + { + yield return null; + Debug.Log($"UnityOneTimeTearDown"); + _oneTimeTeardownCount++; + + Assert.That(_oneTimeTeardownCount, Is.EqualTo(1), "OneTimeTearDownはTestFixtureごとに一度だけ実行される"); + Assert.That(_teardownCount, Is.EqualTo(3), "3つのテストがあるのでTearDownは3回実行されている"); + } + + /// + /// 各テストメソッドの後に実行されます + /// + [TearDown] + public void TearDown() + { + Debug.Log($"TearDown"); + _teardownCount++; + } + + [Test] + public void TestMethod() + { + Debug.Log($"TestMethod"); + } + + [Test] + public async Task TestMethodAsync() + { + await Task.Yield(); + Debug.Log($"TestMethodAsync"); + } + + [UnityTest] + public IEnumerator UnityTestMethod() + { + yield return null; + Debug.Log($"UnityTestMethod"); + } + } +} +#endif diff --git a/Assets/APIExamples/Tests/Editor/UnityTestFramework/UnityOneTimeTearDownAttributeExample.cs.meta b/Assets/APIExamples/Tests/Editor/UnityTestFramework/UnityOneTimeTearDownAttributeExample.cs.meta new file mode 100644 index 0000000..46ac3e2 --- /dev/null +++ b/Assets/APIExamples/Tests/Editor/UnityTestFramework/UnityOneTimeTearDownAttributeExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: fff43dc8c86648aead6768826c0ee184 +timeCreated: 1762467282 \ No newline at end of file diff --git a/Assets/APIExamples/Tests/Runtime/UnityTestFramework/UnityOneTimeSetupAttributeExample.cs b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/UnityOneTimeSetupAttributeExample.cs new file mode 100644 index 0000000..e2711f3 --- /dev/null +++ b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/UnityOneTimeSetupAttributeExample.cs @@ -0,0 +1,75 @@ +// Copyright (c) 2021-2025 Koji Hasegawa. +// This software is released under the MIT License. + +#if ENABLE_UTF_1_5 +using System.Collections; +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; +using APIExamples.NUnit; +using NUnit.Framework; +using UnityEngine.TestTools; +using Is = APIExamples.NUnit.Is; + +namespace APIExamples.UnityTestFramework +{ + /// + /// の使用例 + /// + /// + /// Required: Unity Test Framework v1.5 or later + /// + /// + /// + /// + /// + [TestFixture] + [SuppressMessage("ReSharper", "AccessToStaticMemberViaDerivedType")] + public class UnityOneTimeSetupAttributeExample + { + private int _oneTimeSetupCount; + private int _setupCount; + + /// + /// テストクラス内の最初のテストの実行前に一度だけ実行されます + /// + [UnityOneTimeSetUp] + public IEnumerator OneTimeSetUp() + { + yield return null; + _oneTimeSetupCount++; + } + + /// + /// 各テストメソッドの前に実行されます + /// + [SetUp] + public void SetUp() + { + _setupCount++; + } + + [Test, Order(0)] + public void TestMethod() + { + Assert.That(_oneTimeSetupCount, Is.EqualTo(1), "OneTimeSetUpはTestFixtureごとに一度だけ実行される"); + Assert.That(_setupCount, Is.EqualTo(1), "最初のテストなのでSetUpは1回実行されている"); + } + + [Test, Order(1)] + public async Task TestMethodAsync() + { + await Task.Yield(); + Assert.That(_oneTimeSetupCount, Is.EqualTo(1), "OneTimeSetUpはTestFixtureごとに一度だけ実行される"); + Assert.That(_setupCount, Is.EqualTo(2), "2番目のテストなのでSetUpは2回実行されている"); + } + + [UnityTest, Order(2)] + public IEnumerator UnityTestMethod() + { + yield return null; + Assert.That(_oneTimeSetupCount, Is.EqualTo(1), "OneTimeSetUpはTestFixtureごとに一度だけ実行される"); + Assert.That(_setupCount, Is.EqualTo(3), "3番目のテストなのでSetUpは3回実行されている"); + } + } +} +#endif diff --git a/Assets/APIExamples/Tests/Runtime/UnityTestFramework/UnityOneTimeSetupAttributeExample.cs.meta b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/UnityOneTimeSetupAttributeExample.cs.meta new file mode 100644 index 0000000..6cd45db --- /dev/null +++ b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/UnityOneTimeSetupAttributeExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 229f96c95185415da79ce61b23f777e0 +timeCreated: 1762466846 \ No newline at end of file diff --git a/Assets/APIExamples/Tests/Runtime/UnityTestFramework/UnityOneTimeTearDownAttributeExample.cs b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/UnityOneTimeTearDownAttributeExample.cs new file mode 100644 index 0000000..cdb69ff --- /dev/null +++ b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/UnityOneTimeTearDownAttributeExample.cs @@ -0,0 +1,78 @@ +// Copyright (c) 2021-2025 Koji Hasegawa. +// This software is released under the MIT License. + +#if ENABLE_UTF_1_5 +using System.Collections; +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; +using APIExamples.NUnit; +using NUnit.Framework; +using UnityEngine; +using UnityEngine.TestTools; +using Is = APIExamples.NUnit.Is; + +namespace APIExamples.UnityTestFramework +{ + /// + /// の使用例 + /// + /// + /// Required: Unity Test Framework v1.5 or later + /// + /// + /// + /// + /// + [TestFixture] + [SuppressMessage("ReSharper", "AccessToStaticMemberViaDerivedType")] + public class UnityOneTimeTearDownAttributeExample + { + private int _oneTimeTeardownCount; + private int _teardownCount; + + /// + /// クラス内の最後のテストの実行後に一度だけ実行されます + /// + [UnityOneTimeTearDown] + public IEnumerator OneTimeTearDown() + { + yield return null; + Debug.Log($"UnityOneTimeTearDown"); + _oneTimeTeardownCount++; + + Assert.That(_oneTimeTeardownCount, Is.EqualTo(1), "OneTimeTearDownはTestFixtureごとに一度だけ実行される"); + Assert.That(_teardownCount, Is.EqualTo(3), "3つのテストがあるのでTearDownは3回実行されている"); + } + + /// + /// 各テストメソッドの後に実行されます + /// + [TearDown] + public void TearDown() + { + Debug.Log($"TearDown"); + _teardownCount++; + } + + [Test] + public void TestMethod() + { + Debug.Log($"TestMethod"); + } + + [Test] + public async Task TestMethodAsync() + { + await Task.Yield(); + Debug.Log($"TestMethodAsync"); + } + + [UnityTest] + public IEnumerator UnityTestMethod() + { + yield return null; + Debug.Log($"UnityTestMethod"); + } + } +} +#endif diff --git a/Assets/APIExamples/Tests/Runtime/UnityTestFramework/UnityOneTimeTearDownAttributeExample.cs.meta b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/UnityOneTimeTearDownAttributeExample.cs.meta new file mode 100644 index 0000000..9442aca --- /dev/null +++ b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/UnityOneTimeTearDownAttributeExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cfef6d7d5aab42b1a4fa76ec161a29c4 +timeCreated: 1762466846 \ No newline at end of file From 80182e1cc146e61de6e93fd0c7bbeac27ea979b4 Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Fri, 7 Nov 2025 07:51:39 +0900 Subject: [PATCH 09/11] Add IPrebuildSetupWithTestData examples (UTF 1.6+) --- .../PreBuildSetupAttributeExample.cs | 12 ++--- .../PreBuildSetupExample.cs | 19 +++++-- ...eBuildSetupWithTestDataAttributeExample.cs | 28 ++++++++++ ...dSetupWithTestDataAttributeExample.cs.meta | 3 ++ .../PreBuildSetupWithTestDataExample.cs | 51 +++++++++++++++++++ .../PreBuildSetupWithTestDataExample.cs.meta | 3 ++ 6 files changed, 105 insertions(+), 11 deletions(-) create mode 100644 Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupWithTestDataAttributeExample.cs create mode 100644 Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupWithTestDataAttributeExample.cs.meta create mode 100644 Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupWithTestDataExample.cs create mode 100644 Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupWithTestDataExample.cs.meta diff --git a/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupAttributeExample.cs b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupAttributeExample.cs index 878526e..dd95afc 100644 --- a/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupAttributeExample.cs +++ b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupAttributeExample.cs @@ -7,13 +7,13 @@ namespace APIExamples.UnityTestFramework { /// - /// で指定した実装クラスの`Setup()`メソッドが使用されます + /// で指定した 実装クラスの Setup メソッドが使用されます + /// + /// 複数のテストに PrebuildSetup 属性が配置されていても、Setup の実行は1回だけです + /// を実装していないクラスを渡した場合、何も起きません(エラーにもなりません) + /// PrebuildSetup 属性は、クラスにもメソッドにも配置できます + /// /// - /// - /// - 複数のテストに属性が付与されていた場合、`Setup()`の実行は1回だけです - /// - を実装していないクラスを渡した場合、何も起きません(エラーにもなりません) - /// - 属性は、クラスにもメソッドにも付与できます - /// [PrebuildSetup(typeof(PreBuildSetupExample))] [PostBuildCleanup(typeof(PreBuildSetupExample))] public class PreBuildSetupAttributeExample diff --git a/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupExample.cs b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupExample.cs index 84d2f8c..ec72155 100644 --- a/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupExample.cs +++ b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupExample.cs @@ -2,25 +2,34 @@ // This software is released under the MIT License. using NUnit.Framework; +using UnityEngine; using UnityEngine.TestTools; namespace APIExamples.UnityTestFramework { + /// + /// ビルド前後に処理を挿むための および の実装例 + /// public class PreBuildSetupExample : IPrebuildSetup, IPostBuildCleanup { /// + /// + /// Unityエディター実行(Edit ModeテストおよびPlay Modeテスト)では、すべてのテストの実行に先立って実行されます。 + /// プレイヤー実行(Play Modeテスト)では、ビルド前に実行されます。 + /// public void Setup() { - // Edit ModeテストおよびPlay Modeテスト(Unityエディター実行)では、すべてのテストの実行に先立って実行される - // Play Modeテスト(プレイヤー実行)では、ビルド前に実行される - // テスト用のビルドにのみResourcesに含めたいアセットをコピーする使用例は `LoadAssetExample` を参照してください + Debug.Log("PreBuildSetupExample.Setup"); } /// + /// + /// Unityエディター実行(Edit ModeテストおよびPlay Modeテスト)では、すべてのテストの実行終了後に実行されます。 + /// プレイヤー実行(Play Modeテスト)では、ビルド後に実行されます。 + /// public void Cleanup() { - // Edit ModeテストおよびPlay Modeテスト(Unityエディター実行)では、すべてのテストの実行終了後に実行される - // Play Modeテスト(プレイヤー実行)では、ビルド後に実行される + Debug.Log("PreBuildSetupExample.Cleanup"); } [Test] diff --git a/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupWithTestDataAttributeExample.cs b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupWithTestDataAttributeExample.cs new file mode 100644 index 0000000..3a04121 --- /dev/null +++ b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupWithTestDataAttributeExample.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2021-2025 Koji Hasegawa. +// This software is released under the MIT License. + +#if ENABLE_UTF_1_6 +using NUnit.Framework; +using UnityEngine.TestTools; + +namespace APIExamples.UnityTestFramework +{ + /// + /// で指定した 実装クラスの Setup メソッドが使用されます + /// + /// + /// Required: Unity Test Framework v1.6 or later + /// + /// + [PrebuildSetupWithTestData(typeof(PreBuildSetupWithTestDataExample))] + [PostBuildCleanupWithTestData(typeof(PreBuildSetupWithTestDataExample))] + public class PreBuildSetupWithTestDataAttributeExample + { + [Test] + public void PrebuildSetupWithTestDataAttributeを付与したテストの例() + { + Assert.That(true, Is.True); + } + } +} +#endif diff --git a/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupWithTestDataAttributeExample.cs.meta b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupWithTestDataAttributeExample.cs.meta new file mode 100644 index 0000000..a2af8a7 --- /dev/null +++ b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupWithTestDataAttributeExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0119066ebb6b49a5a0f8268a2db3ac5a +timeCreated: 1762468572 \ No newline at end of file diff --git a/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupWithTestDataExample.cs b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupWithTestDataExample.cs new file mode 100644 index 0000000..5f73ee3 --- /dev/null +++ b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupWithTestDataExample.cs @@ -0,0 +1,51 @@ +// Copyright (c) 2021-2025 Koji Hasegawa. +// This software is released under the MIT License. + +#if ENABLE_UTF_1_6 +using NUnit.Framework; +using UnityEngine; +using UnityEngine.TestTools; + +namespace APIExamples.UnityTestFramework +{ + /// + /// ビルド前後に処理を挿むための および の実装例 + /// + /// + /// Required: Unity Test Framework v1.6 or later + /// + /// + public class PreBuildSetupWithTestDataExample : IPrebuildSetupWithTestData, IPostbuildCleanupWithTestData + { + /// + /// + /// Unityエディター実行(Edit ModeテストおよびPlay Modeテスト)では、すべてのテストの実行に先立って実行されます。 + /// プレイヤー実行(Play Modeテスト)では、ビルド前に実行されます。 + ///

+ /// には、テストモード、テストプラットフォーム、実行されるテストのリストが含まれます + /// + public void Setup(TestData testData) + { + Debug.Log($"PreBuildSetupWithTestDataExample.Setup; testData: {testData}"); + } + + /// + /// + /// Unityエディター実行(Edit ModeテストおよびPlay Modeテスト)では、すべてのテストの実行終了後に実行されます。 + /// プレイヤー実行(Play Modeテスト)では、ビルド後に実行されます。 + ///

+ /// には、テストモード、テストプラットフォーム、実行されるテストのリストが含まれます + /// + public void Cleanup(TestData testData) + { + Debug.Log($"PreBuildSetupWithTestDataExample.Cleanup; testData: {testData}"); + } + + [Test] + public void IPrebuildSetupWithTestDataを実装したテストの例() + { + Assert.That(true, Is.True); + } + } +} +#endif diff --git a/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupWithTestDataExample.cs.meta b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupWithTestDataExample.cs.meta new file mode 100644 index 0000000..a1b4026 --- /dev/null +++ b/Assets/APIExamples/Tests/Runtime/UnityTestFramework/PreBuildSetupWithTestDataExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c99ecd621549428f922e512fc2778c1b +timeCreated: 1762468080 \ No newline at end of file From 1a691f1079fc05970a2833f7cacfa227f386b907 Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Tue, 9 Dec 2025 02:45:36 +0900 Subject: [PATCH 10/11] Install NUnit.Analyzers v3.9.0 via UnityNuGet --- Packages/manifest.json | 1 + Packages/packages-lock.json | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/Packages/manifest.json b/Packages/manifest.json index baf2f65..e9a8033 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -19,6 +19,7 @@ "com.unity.ugui": "2.0.0", "org.nuget.nsubstitute": "5.3.0", "org.nuget.nsubstitute.analyzers.csharp": "1.0.17", + "org.nuget.nunit.analyzers": "3.9.0", "com.unity.modules.accessibility": "1.0.0", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 5525ef4..a7bdafb 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -195,6 +195,13 @@ "dependencies": {}, "url": "https://package.openupm.com" }, + "org.nuget.nunit.analyzers": { + "version": "3.9.0", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://package.openupm.com" + }, "org.nuget.system.diagnostics.eventlog": { "version": "4.7.0", "depth": 2, From 0f68b17161437a39fa762e522f054685226a6972 Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Tue, 9 Dec 2025 02:53:41 +0900 Subject: [PATCH 11/11] Fix assembly references --- .../APIExamples/Tests/Editor/APIExamples.Editor.Tests.asmdef | 3 ++- Assets/APIExamples/Tests/Runtime/APIExamples.Tests.asmdef | 3 ++- .../Tests/Editor/BasicExample.Editor.Tests.asmdef | 3 ++- Assets/BasicExample/Tests/Runtime/BasicExample.Tests.asmdef | 4 ++-- .../Tests/Runtime/TestDoubleExample.Tests.asmdef | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Assets/APIExamples/Tests/Editor/APIExamples.Editor.Tests.asmdef b/Assets/APIExamples/Tests/Editor/APIExamples.Editor.Tests.asmdef index bd148d2..bfbd6f9 100644 --- a/Assets/APIExamples/Tests/Editor/APIExamples.Editor.Tests.asmdef +++ b/Assets/APIExamples/Tests/Editor/APIExamples.Editor.Tests.asmdef @@ -6,7 +6,8 @@ "UnityEditor.TestRunner", "APIExamples.Tests", "UniTask", - "TestHelper" + "TestHelper", + "NUnit.Analyzers_Unity" ], "includePlatforms": [ "Editor" diff --git a/Assets/APIExamples/Tests/Runtime/APIExamples.Tests.asmdef b/Assets/APIExamples/Tests/Runtime/APIExamples.Tests.asmdef index fac6e79..3d1d0a4 100644 --- a/Assets/APIExamples/Tests/Runtime/APIExamples.Tests.asmdef +++ b/Assets/APIExamples/Tests/Runtime/APIExamples.Tests.asmdef @@ -6,7 +6,8 @@ "UnityEditor.TestRunner", "APIExamples", "UniTask", - "TestHelper" + "TestHelper", + "NUnit.Analyzers_Unity" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Assets/BasicExample/Tests/Editor/BasicExample.Editor.Tests.asmdef b/Assets/BasicExample/Tests/Editor/BasicExample.Editor.Tests.asmdef index 625f125..fdc26ab 100644 --- a/Assets/BasicExample/Tests/Editor/BasicExample.Editor.Tests.asmdef +++ b/Assets/BasicExample/Tests/Editor/BasicExample.Editor.Tests.asmdef @@ -6,7 +6,8 @@ "UnityEditor.TestRunner", "BasicExample.Editor", "BasicExample", - "BasicExample.Tests" + "BasicExample.Tests", + "NUnit.Analyzers_Unity" ], "includePlatforms": [ "Editor" diff --git a/Assets/BasicExample/Tests/Runtime/BasicExample.Tests.asmdef b/Assets/BasicExample/Tests/Runtime/BasicExample.Tests.asmdef index 8d5a9f0..af9a3ac 100644 --- a/Assets/BasicExample/Tests/Runtime/BasicExample.Tests.asmdef +++ b/Assets/BasicExample/Tests/Runtime/BasicExample.Tests.asmdef @@ -4,9 +4,9 @@ "references": [ "UnityEngine.TestRunner", "UnityEditor.TestRunner", - "NUnit.Analyzers_Unity", + "BasicExample", "TestHelper", - "BasicExample" + "NUnit.Analyzers_Unity" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Assets/TestDoubleExample/Tests/Runtime/TestDoubleExample.Tests.asmdef b/Assets/TestDoubleExample/Tests/Runtime/TestDoubleExample.Tests.asmdef index 1392188..73e4d45 100644 --- a/Assets/TestDoubleExample/Tests/Runtime/TestDoubleExample.Tests.asmdef +++ b/Assets/TestDoubleExample/Tests/Runtime/TestDoubleExample.Tests.asmdef @@ -5,6 +5,7 @@ "UnityEngine.TestRunner", "UnityEditor.TestRunner", "TestDoubleExample", + "NUnit.Analyzers_Unity", "NSubstitute.Analyzers.CSharp_Unity" ], "includePlatforms": [],