Search Unity

Question Monthly and Weekly updated content - Can I chain it?

Discussion in 'Unity Remote Config' started by TEEBQNE, Feb 24, 2021.

  1. TEEBQNE

    TEEBQNE

    Joined:
    Jan 25, 2017
    Posts:
    88
    I was hoping to implement a rolling remote updated shop in a game I am working on. After doing some research I found Remote Config which seems rather promising. After reading through the docs I have an idea of what I need to do in order to get what I have envisioned working, I just wanted to ask around here to make sure I am using best practices.

    My goal is to update an in-game shop every week with different sales, packs, and other items. In the Remote Config terminal, I would push various JSON data that contains the item, sale, and other data I would need. I can easily set a start and end time for this rule as well. If a user is within the start-end time of a particular JSON object, it can populate the shop with the data.

    My question now is how I should go about updating this weekly or biweekly. My first thought was just to set multiple rules, and have them sync up end->start. Here is an example:

    Pack 1) Start[Monday 12 AM UTC Week 1] - End[Monday 12 AM UTC Week 2]
    Pack 2) Start[Monday 12 AM UTC Week 2] - End[Monday 12 AM UTC Week 3]
    ...
    Pack X)...

    My one concern is if I have two overlapping rules, I can set the weighting to them, so if I prioritize the newer pack if a user logs exactly at 12 AM UTC of Week 2, would it use Pack 2 instead of Pack 1 if the priority was higher for Pack 2 than Pack 1? There are 1000 priority, so if I were to use this system and start at 1000, that means I would have at max 1000 cycles unless I can update priorities on the fly when an old rule is no longer going to be in use.

    To summarize my question, with my example case is how I am approaching using Remote Config the best way to go about it? Or is there a way to chain rules together or have cycled rules so I can link a particular rule to a variable, then depending on the current data set different data. Something like:

    [Packs]
    [Pack1] Rule = Start/End Week 1 -> Week 2
    [Pack2] Rule = Start/End Week 2 -> Week 3

    InGameShopData = Packs[CurrentTime]


    I had one other unrelated question that is regarding the API requests. The documentation says that the Rest API requested whenever a user opens the app or every 30 minutes of inactivity. Is there a way to force this request? The reason is if a user is looking at the store at 12 AM UTC, I would like the data to update when the in-game clock hits this time. Thanks!
     
  2. TEEBQNE

    TEEBQNE

    Joined:
    Jan 25, 2017
    Posts:
    88
    Well, I suppose I answered my own question after digging a bit more and actually implementing what I read from the documentation. I would happily be corrected if what I have done can be simplified or improved.

    I was a bit confused about the difference and connection between rules and variables. I was under the assumption they had a 1:1 connection, but that is in no way correct. Multiple rules can change and affect the same key. Then each variable sets itself off of the key data. So here is how I set up the packs:

    For each pack, I have separate rules that have a start and end date. For the monthly packs, they start at 12 AM UTC on the first day of each month, then end the following month's first day at 12 AM UTC. To account for the overlap, I just set the newer month to a lower priority, then once the new month occurs I would delete the old rule set, and push the priority back to 1000 so I am not restricted to 1000 packs. I would just set the JSON data to whatever I need for the particular pack for that month.

    My second question again was just from me misunderstanding the documentation. Once adding the callback for fetchComplete to a function, calling FetchConfig allows the data to be reloaded. I would check my in-game clock, and if the user has one of the UI open during the time/date change, it would show a loading UI over the existing UI, then fetch.

    Definitely a cool and powerful feature. From what I can tell what I am doing aligns with how Remote Config should be used, but if it can be improved let me know!
     
  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  4. TEEBQNE

    TEEBQNE

    Joined:
    Jan 25, 2017
    Posts:
    88
    Just got back and threw together a test scene. Seems my idea works as intended. Awesome feature thanks!
     
    JeffDUnity3D likes this.