Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Digitex

Cross-promotion Inside Game with updates

Question

Hi everyone,

I'm looking to build a very simple cross promotion system with the following idea:

Create any canevas containing few icons of other of your games with a clickeable game icon. This canevas could be triggered by a click on a more games button or anything else.

The part where I have difficulties is that I want the games that will be shown to be controlled by me.

in other words, I'd like to put the game icon link and game Url outside the game code itself and be able to update the shown games whenever I want without Updating the game inside the store.

I have never done such stuff before, so I'm wondering how could I get a png from a url and put it inside the image component? and also update the Urls to the relevant one

Regards,

Edited by Digitex

Share this post


Link to post
Share on other sites

11 answers to this question

Recommended Posts

  • 0

Just slap it inside a MySQL database and fetch the data whenever needed

Share this post


Link to post
Share on other sites

  • 0

thanks for your answer,

any guide or help: where to search if I want to learn how to do so?

Regards,

Share this post


Link to post
Share on other sites
  • 0

Thank you for this awesome playlist.

I have started to learn from it. I get a weird error, I fail to get the two columns having a VARCHAR type data. It works fine for INT Type (ID and Cost Columns).

Here is the line when I get the error:

Please login or register to see this code.



Secondly, I'd like to know how to handle data other data types like images and insert them inside the database?

Regards,

Please login or register to see this attachment.

Please login or register to see this attachment.

Edited by Digitex

Share this post


Link to post
Share on other sites
  • 0

Seeing as you won't be changing data list of 'other games available' very often and it's just going to be read by players of your game and not changed, I would have kept the information on a static webpage. Just update the webpage with the latest information when you have a new game released. I think using MySQL is overkill.

 

In your games you just need to send a request to the website to get the information.

 

If you have made progress with MySQL then you might as well finish it. But, you can host reliable static webpages completely free (I use Google App Engine) whereas most free MySQL hosts I have come across are not very reliable. Also, the response times would be slightly quicker with a static website.

 

Edit: Plus uploading images with a static website would be easier.

Edited by randomrabbit

Share this post


Link to post
Share on other sites
  • 0

Hi,

thanks for your sharing point of view.

Actually, that's what I tought about in the first place, just uploading a page somewhere where I could change from time to time the data (game link and icon url) while keeping the same url of this file.

But, I want to know how to handle the coding part in Unity?  you know opening a web page, getting a png image and inserting it inside the image component..etc

Regards,

Edited by Digitex

Share this post


Link to post
Share on other sites
  • 0

You just need to send a HTTP Get request to the page from your code

 

In older version of Unity you would use the WWW class. This has been replaced with the UnityWebRequest class.

 

The code on this page of the documentation is exactly what you need to get the contents of a webpage:

Please login or register to see this link.

Note that your page doesn't need to be a html file. It could just be a text file containing the information. More standard formats for storing the data are XML or JSON.

 

Downloading an image from its url is slightly different. Unity keep changing their methods for this. I believe this is now the right one to use:

Please login or register to see this link.

It should provide you with a Please login or register to see this link. .

You can convert this to a Please login or register to see this link. by simply parsing it. Please login or register to see this link. .

And you can create a Sprite from the Texture2D with Please login or register to see this link.

Once you have the sprite you can assign it to your UI Image to display it :).

Share this post


Link to post
Share on other sites
  • 0

thank you so much for those guidelines.

i will apply them as soon as possible.

However, do you have an idea how can handle the file hosting part? I mean I'd like to be able to modify the content of the file that contains imageUrl and link without changing the file link (inside the game): Dropbox or google Drive won't do it as the link change every upload and you can't directly modify the file.

Regards,

Share this post


Link to post
Share on other sites
  • 0

OMA is correct just make sure you 'replace' or 'update' the file rather than deleting and reuploading.

 

You will get a problem if you wish to build to WebGL or WebPlayer though as Unity requires a crossdomain.xml file at the root of the domain which Google Drive and Dropbox don't have. If the file isn't there Unity will block your UnityWebRequests. If you have this problem you'll just need a file host which allows you to put files at the root of the domain so you can put the crossdomain.xml file there i.e. www.example.com/crossdomain.xml. (see Please login or register to see this link. for more info).

As I mentioned earlier I use Google App Engine for hosting which allows you to put the file at this address).

 

All other platforms should work fine with Google Drive or Dropbox.

Share this post


Link to post
Share on other sites
  • 0

Thank you all for your answers.

I have sucessfully implemented the code. As I'm using 5.6 on this project, I had to use the WWW class to get the texture.

 

By the way, I have another question: Is it possible to save the gathered data (sprite and string) inside the device storage? so that the next time, if the internet is disabled the mobile will use the saved data.

Regards,

Edited by Digitex

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...