Skip to content

Unity 6 Updates #239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: unity-sdk-v2.0
Choose a base branch
from
Open

Unity 6 Updates #239

wants to merge 11 commits into from

Conversation

parisacognitive3d
Copy link
Contributor

Description

The following update was made for Unity 6000 and newer versions:

  • Resolved obsolete warnings by updating deprecated API usage

Linear Issue ID(s) (If applicable): SDK-26

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • My changes will not interrupt or disrupt automated build processes
  • I have checked all outgoing links (i.e. to documentation) for validity
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • I have assigned this PR to myself in GitHub
  • I have assigned and notified Reviewers for this PR

Copy link

@alfred316 alfred316 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@matt-manuel matt-manuel requested a review from Copilot July 16, 2025 16:56
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

The PR updates deprecated Unity API calls and introduces a Unity version–guarded await path for web requests to resolve obsolete warnings in Unity 6000 and newer.

  • Replaced all FindObjectOfType() usages with FindFirstObjectByType()
  • Replaced all FindObjectsOfType() usages with FindObjectsByType(FindObjectsSortMode.None)
  • Added a conditional await for UnityWebRequest.SendWebRequest under a new Unity version define

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Runtime/Scripts/GameplayReferences.cs Updated deprecated FindObjectOfType to FindFirstObjectByType
Runtime/Scripts/Cognitive3D_Manager.cs Updated FindObjectOfType to FindFirstObjectByType
Runtime/Internal/NetworkManager.cs Added conditional await for SendWebRequest on Unity 6000+
Runtime/ExitPoll/Scripts/PointerInputHandler.cs Switched FindObjectsOfType to FindObjectsByType
Runtime/ExitPoll/Scripts/MicrophoneButton.cs Switched FindObjectOfType to FindFirstObjectByType
Runtime/Components/OculusPassthrough.cs Switched FindObjectOfType to FindFirstObjectByType
Runtime/Components/OculusHardware.cs Fixed casing for subsystemDescriptor.id
Runtime/Components/Cognitive3D_MetaSceneMesh.cs Updated FindObjectOfType to FindFirstObjectByType
Runtime/ActiveSessionView/Editor/ActiveSessionViewEditor.cs Switched FindObjectOfType to FindFirstObjectByType
Editor/SceneSetupWindow.cs Updated FindObjectOfType to FindFirstObjectByType
Editor/ProjectSetupWindow.cs Updated FindObjectOfType to FindFirstObjectByType
Editor/ExportUtility.cs Replaced FindObjectsOfType with FindObjectsByType
Editor/ExitPollHolderInspector.cs Switched FindObjectOfType to FindFirstObjectByType
Editor/EditorCore.cs Updated PlayerSettings define symbol API
Editor/DynamicObjectsWindow.cs Enhanced dynamic object retrieval to include disabled entries
Editor/DynamicObjectInspector.cs Switched FindObjectsOfType to FindObjectsByType
Editor/DebugWindow.cs Updated FindObjectOfType calls and define symbol API
Comments suppressed due to low confidence (4)

Runtime/Internal/NetworkManager.cs:450

  • Using async void prevents callers from awaiting this method and makes exception handling difficult. Change the signature to return Task to allow proper waiting and error propagation.
            request.SetRequestHeader("Content-Type", "application/json");

Runtime/Internal/NetworkManager.cs:454

  • The new await-based SendWebRequest branch under UNITY_6000_0_OR_NEWER introduces asynchronous behavior that should be covered by tests in both old and new Unity versions.
            await request.SendWebRequest();

Editor/ExportUtility.cs:567

  • [nitpick] Local variable 'SkinnedMeshes' is named with PascalCase, which conflicts with common C# conventions for local variables. Consider renaming to 'skinnedMeshes'.
            SkinnedMeshRenderer[] SkinnedMeshes = UnityEngine.Object.FindObjectsByType<SkinnedMeshRenderer>(FindObjectsSortMode.None);

Editor/DynamicObjectsWindow.cs:617

  • [nitpick] Repeatedly querying FindObjectsOfType can be expensive in large scenes. Consider caching results or limiting calls to improve responsiveness in the editor window.
                    _cachedDynamics = FindObjectsOfType<DynamicObject>();

@@ -450,8 +450,11 @@ internal async void Post(string url, string stringcontent)
request.SetRequestHeader("Content-Type", "application/json");
request.SetRequestHeader("X-HTTP-Method-Override", "POST");
request.SetRequestHeader("Authorization", CognitiveStatics.ApplicationKey);
#if UNITY_6000_0_OR_NEWER
Copy link
Preview

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version define UNITY_6000_0_OR_NEWER does not match Unity's actual scripting define symbols, so this branch may never trigger. Consider using a supported version define (e.g., UNITY_2023_2_OR_NEWER) or a custom define for the new API availability.

Suggested change
#if UNITY_6000_0_OR_NEWER
#if UNITY_2023_2_OR_NEWER

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants