Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question How can I create more config types?

Discussion in 'Unity Remote Config' started by alex11paulescu, Apr 3, 2024.

  1. alex11paulescu

    alex11paulescu

    Joined:
    Sep 6, 2021
    Posts:
    22
    I understand that there is a configType parameter that you can send to the FetchConfigs method to be able to differentiate upon more configs.
    In my software I want to create a form of structure that splits the big remote config file into more, granular configs using this config type.

    So : How do I create more config types? I can not seem to find anything in the WebUI.

    Also, additional question : I can not seem to find a way to add a JEXL condition for a Game Override for customUserId.
    I am using
    Code (CSharp):
    1. RemoteConfigService.Instance.SetCustomUserID()
    to set a custom userId and then in the JEXL :
    app.customUserId == "1234"
    . But it's not working for me. It is not a game override issue as with any other condition it works.
     
    Last edited: Apr 3, 2024
  2. GabKBelmonte

    GabKBelmonte

    Unity Technologies

    Joined:
    Dec 14, 2021
    Posts:
    149
    Hi!

    > there is a configType parameter that you can send to the FetchConfigs method to be able to differentiate upon more configs

    This is used internally to store other configs such as economy or lobby, I dont believe it was intended to be used as dynamic storage capabilities.

    > In my software I want to create a form of structure that splits the big remote config file into more, granular configs using this config type.

    There's 3 quick answers I can help with here.
    1. You can store full json for a given key-value pair. you can use that to organize your settings
    1. you can author separate files from the editor using the com.unity.remote-config and the com.unity.services.deployment packages (some details here)
    2. The runtime api allows you to fetch a subset of keys.

    Ill ask the team about the JEXL question, they might have more insights on the other questions as well.

    Cheers!
     
    vd_unity likes this.
  3. alex11paulescu

    alex11paulescu

    Joined:
    Sep 6, 2021
    Posts:
    22
    Thanks for the prompt answer!

    I wanted to use config types to be able to fetch different subsets of settings, not all settings at once.
    Yes, I am organizing my Remote Config into granular json, but when I call FetchConfigs I don't want to fetch everything in remote. I want to only fetch the keys that are part of a specific config type, but now that you're telling me that it was created for internal use only, I guess this method is not gonna work.

    Regarding fetching a subset of keys within the client : do you have maybe an example code to get me started? Thanks.

    And one more question : Is there any way on the client to know when a Game Override updated a key? An event to which I can subscribe and which is getting triggered when a GameOverride changes value.

    Thanks again.
     
  4. bcamus

    bcamus

    Unity Technologies

    Joined:
    Mar 6, 2023
    Posts:
    8
    Hey!

    Regarding the JEXL question above, it looks like you may need to change the JEXL expression in the Game Override to
    user.customUserId == "1234"
    instead of
    app.customUserId == "1234"
    . The method sets that specific attribute under `user`.

    Doc link if you want to read more on it!

    Regarding Game Overrides, could you clarify if your question is about changes made to Game Overrides themselves or about configuration changes for keys?
    Game Overrides modify the configuration returned to the game client on a dynamic, per request basis for players belonging to selected Audiences or matching the desired JEXL expressions. In that sense, there is not a precise moment where the keys in the base configuration are modified.

    Cheers and let us know if this helps,

    Bert
     
  5. alex11paulescu

    alex11paulescu

    Joined:
    Sep 6, 2021
    Posts:
    22
    Great answer on the JEXL issue. Will test and come back to you!

    Regarding Game Overrides : My question was about changes made to keys.

    I tested it like this : I fetched configs when I started the scene. Then, whenever I pressed a test button I would be fetching the keys again. Between the initial fetch and the button press fetch I would change the key value in the Game Override and when I pressed the button, I could see that I am getting the newly updated value, so Game Override works as intended even in the game.
    But the problem is that I need to fetch the configuration for it to work. So from what you are saying there is no way to dynamically know from the client whenever I made a change of keys in the Unity Dashboard, right? And if this is true, would this ever be counted as a feature?

    Additional Question : It is also related to the fetching of a subset of keys. Let's assume I am running some dynamic events that I configured also with the Remote Config. For these events, I would really need to know if the configuration changes on the server much more often than for regular settings, so that means I would need to do FetchConfigs each time I need it. But the problem is that if I run a FetchConfigs method it will also fetch me ALL the settings I have in RemoteConfig, even though I might only need one JSON key out of the hundreds I have.
    Your colleague suggested I would use the ClientAPI to fetch a subset of keys. Is this the correct approach if I want to only get some specific keys? If it is, do you have any example code for this?

    Thanks for your time and concise answer!
     
  6. vd_unity

    vd_unity

    Unity Technologies

    Joined:
    Sep 11, 2014
    Posts:
    43
    Hey @alex11paulescu
    Regarding fetching the subset of keys, we do have filtering feature
    mentioned in the docs , but it is buried under other information and probably hard to find.
    In short, you can fetch configuration settings using filter attributes, something like this:
    On top of your script declare filterAttributes struct
    Code (CSharp):
    1.  
    2.     public struct filterAttributes {
    3.       // Optionally declare variables for attributes to filter on any of following parameters:
    4.         public string[] key;
    5.         public string[] type;
    6.         public string[] schemaId;
    7.     }
    8.  
    then add it to your FetchConfigs() or FetchConfigsAsync() call, depending on your implementation
    Code (CSharp):
    1.  
    2. var fAttributes = new filterAttributes();
    3. fAttributes.key = new string[] { "sword","cannon" };
    4. RemoteConfigService.Instance.FetchConfigsAsync(new userAttributes(), new appAttributes(), fAttributes);
    5.  
    Bear in mind you can filter on key, type or schemaId.

    I hope this helps a bit!
     
  7. alex11paulescu

    alex11paulescu

    Joined:
    Sep 6, 2021
    Posts:
    22
    Oh, I misread the filter attributes. That's great, thank you very much!
     
    vd_unity likes this.