Search Unity

ads in a multiplayer PC game like a billboard that can be updated/changed over time?

Discussion in 'Editor & General Support' started by Jeepster, Jan 3, 2019.

  1. Jeepster

    Jeepster

    Joined:
    Jan 23, 2014
    Posts:
    179
    Hi,

    I haven't had much luck asking this question to Unity's contact email directly (No answer) and I also posted in the forums before about this with the same result, but here goes nothing:

    Is it possible to make billboard type ads that are visible in-game and update/switch them over time after a build has been sold??

    This is for a multiplayer game that has a field surrounded by boundaries. The ads would exist as still images or sprites on these boundaries and I'd like to be able to change them from time to time without having the customers download an update. I hope this can be done but I can't find answers for PC games. Any help is greatly appreciated.

    Thanks
     
  2. lucernagame

    lucernagame

    Joined:
    Nov 5, 2018
    Posts:
    19
    Yes, it's possible. Also, it should be fairly simple. If you're hosting your own ads, your server content can serve everything together. You will be able to use UnityWWW functions to download images and then programmatically apply them to textures. If you're using an ad network, you can use their API to grab the image and redirect URL. Just run a script that gets that information on the games boot and it can update itself every time the game starts.
     
    Jeepster likes this.
  3. Jeepster

    Jeepster

    Joined:
    Jan 23, 2014
    Posts:
    179
    Great! I know now that it's possible now. The HOW is a lot less simple for me then you make it sound though o_O
    The game is setup with Photon as the server, I will be paying them for that. If the game is released on STEAM for example and hundreds of players buy the game on STEAM (hopefully a lot more) how can I update the ads then?
     
  4. lucernagame

    lucernagame

    Joined:
    Nov 5, 2018
    Posts:
    19
    Since you're using your own server, you can set up a small script to update textures on billboards with:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class ExampleClass : MonoBehaviour
    5. {
    6.     public string url = "https://upload.wikimedia.org/wikipedia/commons/1/19/Unity_Technologies_logo.svg";
    7.     IEnumerator Start()
    8.     {
    9.         using (WWW www = new WWW(url))
    10.         {
    11.             yield return www;
    12.             Renderer renderer = GetComponent<Renderer>();
    13.             renderer.material.mainTexture = www.texture;
    14.         }
    15.     }
    16. }
    Then on your server, you can just change the image at the location you're grabbing it. For example if you have myserver.com/ad1.jpg, you can replace the file with a new one and the most recent file will be downloaded each time. I would recommend, if you could, to make a settings file that would contain most of the info of whether or not to download an ad, it's dimensions, and information they might want so they don't use up too much bandwidth. But if that's more coding than it's worth just use something small like the above.
     
    Jeepster likes this.
  5. Jeepster

    Jeepster

    Joined:
    Jan 23, 2014
    Posts:
    179

    Thank you very much my friend. Well explained and now I think I can make it work.