Skip to content

Commit deea7d2

Browse files
committed
Replace reflection with version-gated conditional compilation.
Addresses review feedback on the Unity 6.5 GetInstanceID migration: - UnityObjectIdCompatExtensions: drop the reflective method lookup in favor of a simple #if UNITY_6000_5_OR_NEWER / #else split calling GetEntityId() or GetInstanceID() directly. Also wrap the class in the MCPForUnity.Runtime.Helpers namespace. - UnityTypeConverters: remove the reflective EntityIdToObject probe and call EditorUtility.EntityIdToObject(EntityId) directly under the same version gate. Serialize entityID as EntityId.ToULong() rather than ToString(), since Unity's docs explicitly warn that the textual form is not a stable serialization contract. - Drop #pragma warning disable 0619 from 22 files that no longer make any direct calls to obsolete APIs. The remaining 7 files still need it (FindObjectsOfType, InstanceIDToObject fallback) and are left as-is — those deprecations are out of scope for this PR. - Add the MCPForUnity.Runtime.Helpers using to every file that calls GetInstanceIDCompat() now that the extension method lives in a namespace.
1 parent f191e73 commit deea7d2

30 files changed

Lines changed: 73 additions & 142 deletions

MCPForUnity/Editor/Helpers/ComponentOps.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#pragma warning disable 0619
21
using System;
32
using System.Collections.Generic;
43
using System.Reflection;
54
using Newtonsoft.Json.Linq;
65
using UnityEditor;
76
using UnityEngine;
87
using UnityEngine.Events;
8+
using MCPForUnity.Runtime.Helpers;
99

1010
namespace MCPForUnity.Editor.Helpers
1111
{

MCPForUnity/Editor/Helpers/GameObjectLookup.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using UnityEditor.SceneManagement;
88
using UnityEngine;
99
using UnityEngine.SceneManagement;
10+
using MCPForUnity.Runtime.Helpers;
1011

1112
namespace MCPForUnity.Editor.Helpers
1213
{

MCPForUnity/Editor/Helpers/GameObjectSerializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#pragma warning disable 0619
21
using System;
32
using System.Collections.Generic;
43
using System.Linq;
@@ -8,6 +7,7 @@
87
using Newtonsoft.Json.Linq;
98
using UnityEditor;
109
using UnityEngine;
10+
using MCPForUnity.Runtime.Helpers;
1111

1212
namespace MCPForUnity.Editor.Helpers
1313
{

MCPForUnity/Editor/Resources/Editor/Selection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#pragma warning disable 0619
21
using System;
32
using System.Linq;
43
using MCPForUnity.Editor.Helpers;
54
using Newtonsoft.Json.Linq;
65
using UnityEditor;
6+
using MCPForUnity.Runtime.Helpers;
77

88
namespace MCPForUnity.Editor.Resources.Editor
99
{

MCPForUnity/Editor/Resources/Editor/Windows.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Newtonsoft.Json.Linq;
66
using UnityEditor;
77
using UnityEngine;
8+
using MCPForUnity.Runtime.Helpers;
89

910
namespace MCPForUnity.Editor.Resources.Editor
1011
{

MCPForUnity/Editor/Resources/Scene/GameObjectResource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#pragma warning disable 0619
21
using System;
32
using System.Collections.Generic;
43
using System.Linq;
54
using MCPForUnity.Editor.Helpers;
65
using Newtonsoft.Json.Linq;
76
using UnityEditor;
87
using UnityEngine;
8+
using MCPForUnity.Runtime.Helpers;
99

1010
namespace MCPForUnity.Editor.Resources.Scene
1111
{

MCPForUnity/Editor/Tools/Cameras/CameraConfigure.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#pragma warning disable 0619
21
using System;
32
using System.Reflection;
43
using MCPForUnity.Editor.Helpers;
54
using Newtonsoft.Json.Linq;
65
using UnityEditor;
76
using UnityEngine;
7+
using MCPForUnity.Runtime.Helpers;
88

99
namespace MCPForUnity.Editor.Tools.Cameras
1010
{

MCPForUnity/Editor/Tools/Cameras/CameraControl.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Newtonsoft.Json.Linq;
88
using UnityEditor;
99
using UnityEngine;
10+
using MCPForUnity.Runtime.Helpers;
1011

1112
namespace MCPForUnity.Editor.Tools.Cameras
1213
{

MCPForUnity/Editor/Tools/Cameras/CameraCreate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#pragma warning disable 0619
21
using System;
32
using System.Collections.Generic;
43
using System.Reflection;
54
using MCPForUnity.Editor.Helpers;
65
using Newtonsoft.Json.Linq;
76
using UnityEditor;
87
using UnityEngine;
8+
using MCPForUnity.Runtime.Helpers;
99

1010
namespace MCPForUnity.Editor.Tools.Cameras
1111
{

MCPForUnity/Editor/Tools/GameObjects/GameObjectDelete.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#pragma warning disable 0619
21
#nullable disable
32
using System.Collections.Generic;
43
using MCPForUnity.Editor.Helpers;
54
using Newtonsoft.Json.Linq;
65
using UnityEditor;
76
using UnityEngine;
7+
using MCPForUnity.Runtime.Helpers;
88

99
namespace MCPForUnity.Editor.Tools.GameObjects
1010
{

0 commit comments

Comments
 (0)