playMaker

Author Topic: Question about database with pictures and text  (Read 2196 times)

ilovelessons

  • Junior Playmaker
  • **
  • Posts: 70
Question about database with pictures and text
« on: October 19, 2017, 11:43:49 PM »
Hi,

Presently i know how to make standard database after watching the following tutorial:


however my question in regarding PNGs and Text.  I am making a game with a lot of PNGs (approx 100) and each PNG has a certain Text associated with it.  Can anyone guide me on how to make a database involving text and pictures?

I usually make quiz (trivia) games using Microsoft excel and then convert the questions and answers from excel to an XML file and import it to Unity. But I have no idea how to handle pngs (pictures).

Any ideas?

Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Question about database with pictures and text
« Reply #1 on: October 20, 2017, 02:32:18 AM »
Hi,

 I would go with this solution:

- have all your png inside your Project under Resources. then they only get loaded on demand ( search for Resource on the Ecosystem and learn about Resources on Unity docs)

- maintain a strict naming conventions for your resources path and file names,

- in your database refer to these images using that convention ( maybe just the name, or maybe the path as well, it depends how you organized it, but the less the better).

- then you never deal with the images during your logi, you deal with a reference to them images, and then at the very last moment you simply load that image from resources and use it visually.

 Does that make sense?

 bye,

 Jean

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
Re: Question about database with pictures and text
« Reply #2 on: October 20, 2017, 05:46:05 AM »
More difficult approach but it's what I would do:

You can have an api that communicates with the database (written in php or asp.net), it would handle the models and pass the data from database to whatever client communicates with it for ex. Unity3D. Unity3D would just use rest+json to communicate with api. Then you can also have a logic for saving data for offline use. Note though that in database you woudn't actually store the images, you would just store the reference like url.

ilovelessons

  • Junior Playmaker
  • **
  • Posts: 70
Re: Question about database with pictures and text
« Reply #3 on: October 20, 2017, 09:01:02 AM »
Thanks elusiven and Jean.

I'll try it out and get back to you guys.. thanks a million

ilovelessons

  • Junior Playmaker
  • **
  • Posts: 70
Re: Question about database with pictures and text
« Reply #4 on: October 22, 2017, 07:13:07 PM »
Hi Jean (or anyone else who can assist :) ),

I downloaded the Resources from ECOSYSTEM and was trying to use it. Before I get to the question let me explain what I am trying to do.

I have a button (UI element) and using Resources I would like to load a picture (a .png image) and then change the picture of my button using the image i just loaded using resources.

However when I load the png image using resources I do not know what to use as the TYPE field. I have attached picture of all the TYPEs available.  I did not see any  listed as IMAGE.  Any ideas what to choose for the TYPE?


I tried to attach the picture but for some reason the forum isn't allowing me to upload the picture. So I am typing out the TYPE options below -

-Float
-Int
-Bool
-Game Object
-String
-Vector 2 and 3
- Color
-Rect
- Material
- Texture
-Quanaternion
-Object
-Array-Enum

Thanks guys.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Question about database with pictures and text
« Reply #5 on: October 23, 2017, 02:56:43 AM »
Hi,

 if you want your png to be a texture, then you can use FsmTexture. if you want your png to be a sprite, then you use FsmObject of type sprite.

 Bye,

 Jean