Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Remote config retrieved multipule times (+1 every play)

Discussion in 'Unity Remote Config' started by nobluff67, May 6, 2023.

  1. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    338
    Hi,

    I run the remote config in the editor, and each time it runs it fetches and extra time. So in other words if I press play the first time it runs once, and on the 10th play it fetches 10 times. The only way it reset to once is when I make any code change and unity compiles. Code is 100% based on the sample code, no changes.

    This doesn't happen in a new project.
    It does happen when I create a new scene in current project.
    I have deleted library and that did not help.
    I have created a different remote environment, that doesn't help.

    Has anyone come across this? Are there any suggestions on what I can try?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,521
    You probably have a static event handler and forget to unregister the event and/or you have domain reload disabled. Is that a possibility? Because that will give you this exact behaviour including resetting only on recompile.

    Also if you use a lambda you cannot unregister that.

    Like this:
    Code (csharp):
    1. some.event += () => {}
    2. some.event -= () => {}
    This leaves the original event lambda registered because these two lambdas are seperate instances (imagine a “new” keyword in front of them).
     
    nobluff67 likes this.
  3. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    338
    Thanks was exactly what it was (unregister the event), thanks for helping with my sanity.