René's URL Explorer Experiment


Title: How about a NetworkBehaviourReference? · Issue #2837 · Unity-Technologies/com.unity.netcode.gameobjects · GitHub

Open Graph Title: How about a NetworkBehaviourReference? · Issue #2837 · Unity-Technologies/com.unity.netcode.gameobjects

X Title: How about a NetworkBehaviourReference? · Issue #2837 · Unity-Technologies/com.unity.netcode.gameobjects

Description: It would be amazing if RPC arguments could just actually be any NetworkBehaviour derivative class instead of only NetworkBehaviourReference so that the compiler could enforce type on those RPC arguments instead of boilerplate cast / TryG...

Open Graph Description: It would be amazing if RPC arguments could just actually be any NetworkBehaviour derivative class instead of only NetworkBehaviourReference so that the compiler could enforce type on those RPC argu...

X Description: It would be amazing if RPC arguments could just actually be any NetworkBehaviour derivative class instead of only NetworkBehaviourReference so that the compiler could enforce type on those RPC argu...

Opengraph URL: https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2837

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"How about a NetworkBehaviourReference\u003cT>?","articleBody":"It would be amazing if RPC arguments could just actually be any `NetworkBehaviour` derivative class instead of only `NetworkBehaviourReference` so that the compiler could enforce type on those RPC arguments instead of boilerplate cast / TryGet code.\r\n\r\nShort of that, doing an RPC with `NetworkBehaviourReference\u003cMyNetworkBehaviourClass>` at least gives me peace of mind that the compiler can catch me trying to pass the RPC a reference to a `NetworkBehaviour` that isn't a `MyNetworkBehaviourClass`.\r\n\r\nI did it like this:\r\n\r\n```\r\nusing System;\r\nusing System.Runtime.CompilerServices;\r\n\r\nnamespace Unity.Netcode\r\n{\r\n    public struct NetworkBehaviourReference\u003cT> : INetworkSerializable, IEquatable\u003cNetworkBehaviourReference\u003cT>>\r\n        where T : NetworkBehaviour\r\n    {\r\n        private NetworkObjectReference m_NetworkObjectReference;\r\n        private ushort m_NetworkBehaviourId;\r\n\r\n        public NetworkBehaviourReference(NetworkBehaviour networkBehaviour)\r\n        {\r\n            if (networkBehaviour == null)\r\n            {\r\n                m_NetworkObjectReference = new NetworkObjectReference((NetworkObject)null);\r\n                m_NetworkBehaviourId = 0;\r\n                return;\r\n                // throw new ArgumentNullException(nameof(networkBehaviour));\r\n            }\r\n            if (networkBehaviour.NetworkObject == null)\r\n            {\r\n                throw new ArgumentException($\"Cannot create {nameof(NetworkBehaviourReference\u003cT>)} from {nameof(NetworkBehaviour)} without a {nameof(NetworkObject)}.\");\r\n            }\r\n\r\n            m_NetworkObjectReference = networkBehaviour.NetworkObject;\r\n            m_NetworkBehaviourId = networkBehaviour.NetworkBehaviourId;\r\n        }\r\n\r\n        public bool TryGet(out T networkBehaviourSubtype, NetworkManager networkManager = null)\r\n        {\r\n            networkBehaviourSubtype = GetInternal(this, null) as T;\r\n            return networkBehaviourSubtype != null;\r\n        }\r\n\r\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n        private static NetworkBehaviour GetInternal(NetworkBehaviourReference\u003cT> networkBehaviourRef, NetworkManager networkManager = null)\r\n        {\r\n            if (networkBehaviourRef.m_NetworkObjectReference.TryGet(out NetworkObject networkObject, networkManager))\r\n            {\r\n                return networkObject.GetNetworkBehaviourAtOrderIndex(networkBehaviourRef.m_NetworkBehaviourId);\r\n            }\r\n\r\n            return null;\r\n        }\r\n\r\n        public bool Equals(NetworkBehaviourReference\u003cT> other)\r\n        {\r\n            return m_NetworkObjectReference.Equals(other.m_NetworkObjectReference) && m_NetworkBehaviourId == other.m_NetworkBehaviourId;\r\n        }\r\n\r\n        public override bool Equals(object obj)\r\n        {\r\n            return obj is NetworkBehaviourReference\u003cT> other && Equals(other);\r\n        }\r\n\r\n        public override int GetHashCode()\r\n        {\r\n            unchecked\r\n            {\r\n                return (m_NetworkObjectReference.GetHashCode() * 397) ^ m_NetworkBehaviourId.GetHashCode();\r\n            }\r\n        }\r\n\r\n        public void NetworkSerialize\u003cT>(BufferSerializer\u003cT> serializer) where T : IReaderWriter\r\n        {\r\n            m_NetworkObjectReference.NetworkSerialize(serializer);\r\n            serializer.SerializeValue(ref m_NetworkBehaviourId);\r\n        }\r\n\r\n        public static implicit operator T(NetworkBehaviourReference\u003cT> networkBehaviourRef) => GetInternal(networkBehaviourRef) as T;\r\n\r\n        public static implicit operator NetworkBehaviourReference\u003cT>(T networkBehaviourSubtype) => new NetworkBehaviourReference\u003cT>(networkBehaviourSubtype);\r\n    }\r\n}\r\n\r\n```","author":{"url":"https://github.com/zachstronaut","@type":"Person","name":"zachstronaut"},"datePublished":"2024-03-05T00:24:51Z","url":"https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2837"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:6dec7615-6928-1bcf-c129-8b781c88046b
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD062:15E965:159703:1E130A:6B0055D0
html-safe-noncea31a03c9956590ec227b7508203f246ae6897ff6e5eee4df38766bd5b936b77f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMDYyOjE1RTk2NToxNTk3MDM6MUUxMzBBOjZCMDA1NUQwIiwidmlzaXRvcl9pZCI6IjE0MTQyMDMwNTAxMjU0NDg2NTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmace6dc2d373e161331ff62b58c9facceab0e3de1891ddae4ab2122da97f301f36b
hovercard-subject-tagissue:2168039617
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/Unity-Technologies/com.unity.netcode.gameobjects/2837/issue_layout
twitter:imagehttps://opengraph.githubassets.com/605cef77b7a5c02b5cf1cf9d9e749d9974e5eb89690af43113347382cbc3fd93/Unity-Technologies/com.unity.netcode.gameobjects/issues/2837
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/605cef77b7a5c02b5cf1cf9d9e749d9974e5eb89690af43113347382cbc3fd93/Unity-Technologies/com.unity.netcode.gameobjects/issues/2837
og:image:altIt would be amazing if RPC arguments could just actually be any NetworkBehaviour derivative class instead of only NetworkBehaviourReference so that the compiler could enforce type on those RPC argu...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamezachstronaut
hostnamegithub.com
expected-hostnamegithub.com
Nonef420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb
turbo-cache-controlno-preview
go-importgithub.com/Unity-Technologies/com.unity.netcode.gameobjects git https://github.com/Unity-Technologies/com.unity.netcode.gameobjects.git
octolytics-dimension-user_id426196
octolytics-dimension-user_loginUnity-Technologies
octolytics-dimension-repository_id116385203
octolytics-dimension-repository_nwoUnity-Technologies/com.unity.netcode.gameobjects
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id116385203
octolytics-dimension-repository_network_root_nwoUnity-Technologies/com.unity.netcode.gameobjects
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release26e00df917aba0f128135dc073ea0c5e33a70d40
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2837#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FUnity-Technologies%2Fcom.unity.netcode.gameobjects%2Fissues%2F2837
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FUnity-Technologies%2Fcom.unity.netcode.gameobjects%2Fissues%2F2837
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=Unity-Technologies%2Fcom.unity.netcode.gameobjects
Reloadhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2837
Reloadhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2837
Reloadhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2837
Unity-Technologieshttps://github.com/Unity-Technologies
com.unity.netcode.gameobjectshttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects
Codehttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects
Issues35 (35)https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues
Pull requests27 (27)https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/pulls
Actionshttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/actions
Security and qualityhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/security
Insightshttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/insights
https://github.com/Unity-Technologies/com.unity.netcode.gameobjects
New issuehttps://github.com/login?return_to=https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2837
New issuehttps://github.com/login?return_to=https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2837
How about a NetworkBehaviourReference?https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2837#top
type:featureNew feature, request or improvementhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22type%3Afeature%22
https://github.com/zachstronaut
zachstronauthttps://github.com/zachstronaut
on Mar 5, 2024https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2837#issue-2168039617
zachstronauthttps://github.com/zachstronaut
stat:awaiting-triageStatus - Awaiting triage from the Netcode team.https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22stat%3Aawaiting-triage%22
type:featureNew feature, request or improvementhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22type%3Afeature%22
on Mar 5, 2024https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2837#event-12006461038
https://github.com/NoelStephensUnity
NoelStephensUnityhttps://github.com/NoelStephensUnity
on Mar 21, 2024https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2837#issuecomment-2014002917
michalChrobothttps://github.com/michalChrobot
stat:reply-neededAwaiting reply from Unity accounthttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22stat%3Areply-needed%22
stat:awaiting-triageStatus - Awaiting triage from the Netcode team.https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22stat%3Aawaiting-triage%22
on Apr 1, 2025https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2837#event-17076783784
michalChrobothttps://github.com/michalChrobot
stat:reply-neededAwaiting reply from Unity accounthttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22stat%3Areply-needed%22
on Apr 10, 2025https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2837#event-17202696602
Sign up for freehttps://github.com/signup?return_to=https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2837
Sign in to commenthttps://github.com/login?return_to=https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2837
type:featureNew feature, request or improvementhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22type%3Afeature%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.