René's URL Explorer Experiment


Title: NetworkVariable.OnValueChanged is not called on the client unless the change took place while the object existed on the client · Issue #2318 · Unity-Technologies/com.unity.netcode.gameobjects · GitHub

Open Graph Title: NetworkVariable.OnValueChanged is not called on the client unless the change took place while the object existed on the client · Issue #2318 · Unity-Technologies/com.unity.netcode.gameobjects

X Title: NetworkVariable.OnValueChanged is not called on the client unless the change took place while the object existed on the client · Issue #2318 · Unity-Technologies/com.unity.netcode.gameobjects

Description: Description leaving original title and description for context. NetworkShow does not set NetworkVariables When we call NetworkHide on a dynamically created object, and later call NetworkShow, the object's network variables are not set. N...

Open Graph Description: Description leaving original title and description for context. NetworkShow does not set NetworkVariables When we call NetworkHide on a dynamically created object, and later call NetworkShow, the o...

X Description: Description leaving original title and description for context. NetworkShow does not set NetworkVariables When we call NetworkHide on a dynamically created object, and later call NetworkShow, the o...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"NetworkVariable.OnValueChanged is not called on the client unless the change took place while the object existed on the client","articleBody":"### Description\r\nleaving original title and description for context.\r\n\r\n> NetworkShow does not set NetworkVariables\r\n\r\n> When we call NetworkHide on a dynamically created object, and later call NetworkShow, the object's network variables are not set.\r\n> NetworkHide will despawn and destroy the object on the client, so when the server calls NetworkShow, we are now creating a new object on the client, except this time the network variables don't get set.\r\n\r\nUpon further testing, the issue turned out to be that NetworkVariable.OnValueChanged is not being called on the client, UNLESS the value changed while the network object existed on the client.\r\n\r\nSo if the client connects, and the network variable already had its value set on the server, OnValueChanged will not get called on the client.\r\nSimilarly, if the object is network hidden on the client side, when it becomes shown again, OnValueChanged is not called for the network variable; for a dynamically created network object it also gets destroyed on the client, not just network hidden.\r\n\r\nNot sure if the parent hierarchy is playing a role here, but my network object is a child of another network object.\r\n\r\nFor the test, I have a Canvas that's an in-scene network object, then I dynamically (at run time) add a network object child to it (on the server), this network object has the behavior below, then I spawn this network object.\r\n\r\n\r\n```\r\npublic class TestBehaviour : NetworkBehaviour\r\n    {\r\n        NetworkVariable\u003cfloat> _networkVariable;\r\n\r\n        [SerializeField]\r\n        private TMP_Text _text;\r\n\r\n        private void Awake()\r\n        {\r\n            _networkVariable = new NetworkVariable\u003cfloat>();\r\n            _networkVariable.OnValueChanged += OnNetworkVariableChanged;\r\n        }\r\n\r\n        private void OnNetworkVariableChanged(float previousValue, float newValue)\r\n        {\r\n          text.text = _networkVariable.Value.ToString();\r\n        }\r\n\r\n        private void Update()\r\n        {\r\n            if (_networkVariable != null)\r\n            {\r\n                _text.text = _networkVariable.Value.ToString();\r\n            }\r\n        }\r\n\r\n        public override async void OnNetworkSpawn()\r\n        {\r\n            if (!NetworkManager.Singleton.IsServer)\r\n            {\r\n                return;\r\n            }\r\n\r\n            await new WaitForSeconds(10); // give time for client to connect.\r\n            _networkVariable.Value = 69; // by now client connected, the client will have OnNetworkVariableChanged raised here.\r\n            await new WaitForSeconds(10);\r\n            NetworkObject.NetworkHide(1);\r\n            _networkVariable.Value = 12; // here we change the value while the object is hidden for the client\r\n            await new WaitForSeconds(10);\r\n            NetworkObject.NetworkShow(1); // here we show the object to the client, since this object is dynamically created, a new instance will be created, BUT OnNetworkVariableChanged is never raised.\r\n        }\r\n    }\r\n```\r\n\r\nWhile inspecting this scene on the client side in the editor, I see everything behaving properly except for that OnNetworkVariableChanged method, it does not get raised unless a change took place while the network object existed.\r\n\r\n\r\nThis issue was not present in Netcode v1.0.0, I started experiencing it in v1.1.0\r\n\r\n### Actual Outcome\r\n\r\nNetworkVariable.OnValueChanged is not called on the client unless the change took place while the object existed on the client.\r\n\r\n### Expected Outcome\r\n\r\nNetworkVariable.OnValueChanged should be called when the variable's value changes, regardless if the change took place while the object existed on the client or not.\r\n\r\n\r\n### Environment\r\n\r\n- OS: Win10\r\n- Unity Version: 2022.1.23f1\r\n- Netcode Version: 1.1.0","author":{"url":"https://github.com/TheCaveOfWonders","@type":"Person","name":"TheCaveOfWonders"},"datePublished":"2022-11-19T18:28:27Z","url":"https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318"}

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:a730256e-4182-5da7-9312-3f2834f5a5ca
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9228:2ED6B1:396A7C:5080AF:6B005E3C
html-safe-nonce09b942da9552f3cc472973831a9470762059d1727e9eb12b8feff8170d033fb5
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MjI4OjJFRDZCMTozOTZBN0M6NTA4MEFGOjZCMDA1RTNDIiwidmlzaXRvcl9pZCI6IjEzNTc5Nzg4NTczMTkxOTQxNzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac9f2f85376190f369455149317dbd104222517bd56c2a790ceea235b6b36e788e
hovercard-subject-tagissue:1456612073
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/2318/issue_layout
twitter:imagehttps://opengraph.githubassets.com/6ca2b8f46cd3e0ac5c31eaa2eaa1d8c5bb53b907cb56ddc8e0f58d019aa9b226/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6ca2b8f46cd3e0ac5c31eaa2eaa1d8c5bb53b907cb56ddc8e0f58d019aa9b226/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318
og:image:altDescription leaving original title and description for context. NetworkShow does not set NetworkVariables When we call NetworkHide on a dynamically created object, and later call NetworkShow, the o...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameTheCaveOfWonders
hostnamegithub.com
expected-hostnamegithub.com
None29be975efff6507a5d135de9c7d634cf7ff8f0c55222a64386ab3202209aaf73
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
releaseeacd927ba6112e3b01ba99c762bd699a4a4f5df7
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#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%2F2318
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%2F2318
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/2318
Reloadhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318
Reloadhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318
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/2318
New issuehttps://github.com/login?return_to=https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318
NetworkVariable.OnValueChanged is not called on the client unless the change took place while the object existed on the clienthttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#top
https://github.com/mtarzwell
priority:mediumThis issue has medium priority and may take some time to be resolvedhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22priority%3Amedium%22
stat:importedStatus - Issue is tracked internally at Unityhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22stat%3Aimported%22
https://github.com/TheCaveOfWonders
TheCaveOfWondershttps://github.com/TheCaveOfWonders
on Nov 19, 2022https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#issue-1456612073
Nexthttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318?timeline_page=1
TheCaveOfWondershttps://github.com/TheCaveOfWonders
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:bugBug Reporthttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22type%3Abug%22
on Nov 19, 2022https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#event-7850067528
jeffreyrainyhttps://github.com/jeffreyrainy
on Nov 21, 2022https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#event-7858453316
https://github.com/jeffreyrainy
jeffreyrainyhttps://github.com/jeffreyrainy
on Nov 21, 2022https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#issuecomment-1322260514
https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/releaseshttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/releases
2c69184https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/commit/2c69184e5f85a025455c415145be3eeecbf98446
https://github.com/TheCaveOfWonders
TheCaveOfWondershttps://github.com/TheCaveOfWonders
on Nov 22, 2022https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#issuecomment-1323982439
ashwinimurthttps://github.com/ashwinimurt
stat:importStatus - Issue is going to be saved internallyhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22stat%3Aimport%22
stat:awaiting-responseAwaiting response from author. This label should be added manually.https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22stat%3Aawaiting-response%22
priority:mediumThis issue has medium priority and may take some time to be resolvedhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22priority%3Amedium%22
stat:importedStatus - Issue is tracked internally at Unityhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22stat%3Aimported%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
stat:importStatus - Issue is going to be saved internallyhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22stat%3Aimport%22
on Nov 22, 2022https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#event-7871120217
https://github.com/ashwinimurt
ashwinimurthttps://github.com/ashwinimurt
on Nov 22, 2022https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#issuecomment-1324362586
MTT-5119https://jira.unity3d.com/browse/MTT-5119
https://github.com/TheCaveOfWonders
TheCaveOfWondershttps://github.com/TheCaveOfWonders
on Nov 23, 2022https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#issuecomment-1324628405
TheCaveOfWondershttps://github.com/TheCaveOfWonders
on Nov 23, 2022https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#event-7874351109
https://github.com/jeffreyrainy
jeffreyrainyhttps://github.com/jeffreyrainy
on Nov 23, 2022https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#issuecomment-1325371262
@TheCaveOfWondershttps://github.com/TheCaveOfWonders
https://github.com/TheCaveOfWonders
TheCaveOfWondershttps://github.com/TheCaveOfWonders
on Nov 24, 2022https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#issuecomment-1326623969
jeffreyrainyhttps://github.com/jeffreyrainy
on May 3, 2023https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#event-9158385869
NoelStephensUnityhttps://github.com/NoelStephensUnity
NoelStephensUnityhttps://github.com/NoelStephensUnity
mtarzwellhttps://github.com/mtarzwell
NoelStephensUnityhttps://github.com/NoelStephensUnity
on May 12, 2023https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#event-9235595080
mtarzwellhttps://github.com/mtarzwell
stat:awaiting-responseAwaiting response from author. This label should be added manually.https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22stat%3Aawaiting-response%22
on May 24, 2023https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#event-9331323464
NoelStephensUnityhttps://github.com/NoelStephensUnity
TrackingHas been added to trackinghttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22Tracking%22
on Jan 7, 2025https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#event-15845496882
michalChrobothttps://github.com/michalChrobot
Investigatinghttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22Investigating%22
Investigatinghttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22Investigating%22
on Jan 16, 2025https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#event-15963172664
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 1, 2025https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#event-17076974774
EmandMhttps://github.com/EmandM
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
type:bugBug Reporthttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22type%3Abug%22
on Apr 8, 2025https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#event-17174223562
https://github.com/EmandM
EmandMhttps://github.com/EmandM
on Jun 23, 2025https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#issuecomment-2997039471
#3186https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/3186
#3186https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/3186
EmandMhttps://github.com/EmandM
duplicatehttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Aduplicate
Automatically invoke NetworkVariable.OnValueChanged when spawning #3186https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/3186
on Jun 23, 2025https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#event-18276820506
github-actionshttps://github.com/apps/github-actions
TrackingHas been added to trackinghttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22Tracking%22
on Jun 23, 2025https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318#event-18276823149
Sign up for freehttps://github.com/signup?return_to=https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318
Sign in to commenthttps://github.com/login?return_to=https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2318
mtarzwellhttps://github.com/mtarzwell
priority:mediumThis issue has medium priority and may take some time to be resolvedhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22priority%3Amedium%22
stat:importedStatus - Issue is tracked internally at Unityhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22stat%3Aimported%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.