Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

userAttributes and appAttributes

Discussion in 'Unity Remote Config' started by YJack, Dec 26, 2019.

  1. YJack

    YJack

    Joined:
    Apr 7, 2010
    Posts:
    44
    Started to play with Remote Config today...
    These two structs (userAttributes and appAttributes) are required by FetchConfigs method.
    However, I'm confused on what is suppose to be in each of these structs.

    Some questions....
    .AppConfig is related to whatever is in ConfigManager.appConfig?
    .userAttributes have a preview in Dashboard or somewhere else?
    .What sort of attributes can come in that userAttribute?
    .Each player have one userAttribute?
    .Each player have one AppAttribute?
    .How can I clean my cached result?
     
  2. rambod

    rambod

    Unity Technologies

    Joined:
    Mar 2, 2018
    Posts:
    57
    Hey @YJack!

    with regards to your questions:
    • AppConfig is related to what's in ConfigManager.appConfig. But AppAttributes and UserAttributes are used by the conditions in remote config rules. They're for you to create, if you don't need them, in the newer packages, you should be able to pass in null.
    • Any public serializable field you put in your attributes structs can be used in rules for segmentation.
    • Each request can have one user and app attribute struct, you could pass different structs into each request. There currently isn't a limit on the number of attributes.
    • There's no way to currently clear the cache result, other than looking through the package source and removing the file where we write the cached results to. Out of curiosity, what's your use case for wanting to clear the cache?
    Hope those help, let me know if you have more questions!
     
  3. YJack

    YJack

    Joined:
    Apr 7, 2010
    Posts:
    44
    Thanks for the answer @rambod
    I'm probably missing something but...
    In short terms, I want to force the usage of a remote data for debugging and clear cache could be helpful in that case. Also, I want to be 100% sure that any value I got is not from a cached result but from the remote data I'm tweaking. ConfigResponse.requestOrigin helps on that but once you notice that you're using the cached version, there's not much to do but to restart Unity or investigate the package source to find out the cached file as you've mentioned.

    Regarding to the previous questions....
    How to preview userAttribute data in server?
     
    Last edited: Jan 11, 2020
  4. vd_unity

    vd_unity

    Unity Technologies

    Joined:
    Sep 11, 2014
    Posts:
    21
    Hi @YJack!
    I am not 100% sure if I understand the clear cache use case so please correct me if I did not get it right,
    but one way to ensure you got the remote data is to check for `ConfigOrigin.Remote` in configResponse after FetchConfigs(), and then apply your overwrites.
    That would overwrite your cache file with new remote values, so there is no need to restart Unity or investigate the package source.
    Of course, you can call FetchConfigs more than once within your session, if you have need for it.

    From the docs:

    Code (CSharp):
    1. // Retrieve and apply the current key-value pairs from the service on Awake:
    2. void Awake () {
    3.  
    4. // Add a listener to apply settings when successfully retrieved:
    5. ConfigManager.FetchCompleted += ApplyRemoteSettings;
    6.  
    7. // Set the user’s unique ID:
    8. ConfigManager.SetCustomUserID("some-user-id");
    9.  
    10. // Fetch configuration setting from the remote service:
    11. ConfigManager.FetchConfigs(new userAttributes(), new appAttributes());
    12.  
    13. }
    14.  
    15.  
    16. void ApplyRemoteSettings (ConfigResponse configResponse) {
    17.  
    18.     // Conditionally update settings, depending on the response's origin:
    19.     switch (configResponse.requestOrigin) {
    20.  
    21.         case ConfigOrigin.Default:
    22.             Debug.Log ("No settings loaded this session; using default values.");
    23.             break;
    24.  
    25.         case ConfigOrigin.Cached:
    26.             Debug.Log ("No settings loaded this session; using cached values from a previous session.");
    27.             break;
    28.  
    29.         case ConfigOrigin.Remote:
    30.             Debug.Log ("New settings loaded this session; update values accordingly.");
    31.             enemyHealth = ConfigManager.appConfig.GetInt ("enemyHealth");
    32.             assignmentId = ConfigManager.appConfig.assignmentID;
    33.             break;
    34.     }
    35.  
    36. }
     
    JeffDUnity3D likes this.
  5. rambod

    rambod

    Unity Technologies

    Joined:
    Mar 2, 2018
    Posts:
    57
    As for this part, it's not something we support today, but if you could give me some more details on what you'd like to see and do with that, I can get it documented as a feature request on our end.
     
  6. YJack

    YJack

    Joined:
    Apr 7, 2010
    Posts:
    44
    Again. I'm pretty new on that so please, let me know if I'm missing something,
    I'll give some examples from the top of my mind...
    So I've added some userAttribute to my player... let's say.... "XP".
    I can see the following circunstancies happening:
    . I'm debugging this feature want to check if the right set/get "XP" value worked as expected consulting that value into the remote config based on my playerID.
    . I decide to rename or remove this "XP" value.
    . I decide to manually change that value for a single player.
    . I decide to change all "XP" value for all my players.
     
  7. rambod

    rambod

    Unity Technologies

    Joined:
    Mar 2, 2018
    Posts:
    57
    @YJack no worries!

    I'm trying to better understand the use case you have above. Is that you want a key "XP" in Remote Config that you want to send down to players? Or do you want players to receive different values for keys based on how much XP they have?
     
  8. YJack

    YJack

    Joined:
    Apr 7, 2010
    Posts:
    44
    want players to receive different values for keys based on how much XP they have.
     
  9. rambod

    rambod

    Unity Technologies

    Joined:
    Mar 2, 2018
    Posts:
    57
    Perfect, okay, so for that, here's what you'd probably want:
    1. Add a variable to your userAttributes struct, like "totalXp" and set that before fetching your config.
    2. In your config, set up whatever variables you'd want changed based on the XP of the player, and implement the runtime Remote Config code in your project.
    3. You can create rules, where in the condition you can do things like "user.totalXp > 0 && user.totalXp <= 1000" let's say. This rule will now go into effect for users whose xp is between 0 and 1000. In the rule, you can specify your override values that you'd like this user group to receive.
    4. Repeat the above steps with as many rules as you need for your user groups.
    Hopefully this helps, but let me know if anything is unclear!
     
  10. magnusfox

    magnusfox

    Joined:
    Nov 7, 2014
    Posts:
    22
    I can not speak for YJack's needs, but one clear use case would be to provide auto-complete when defining rules using conditions for user.* and app.* in the rule editor.
     
    YJack and rambod like this.
  11. agurskis22cans

    agurskis22cans

    Joined:
    Jul 17, 2019
    Posts:
    9
    This please. Allowing to TYPE rules for designers is prone to human error. TYPO in variable name, and the rule doesn't work. No information or warning until you notice that it doesn't work in the game.