Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using MySql.Data.MySqlClient;
- using System;
- using UnityEngine.UI;
- using TMPro;
- public class DownloadIdeas : MonoBehaviour
- {
- public GameObject PrefabIdeaInCategories;
- public Transform[] CategoryParrents;
- private void Start()
- {
- MainFunction();
- }
- public void MainFunction()
- {
- Download(CategoryParrents[0], "CLPKonwersacje", 0);
- Download(CategoryParrents[1], "CLPSlownictwo", 1);
- Download(CategoryParrents[2], "CLPPisanie", 2);
- Download(CategoryParrents[3], "CLPPracaZTekstem", 3);
- Download(CategoryParrents[4], "CLPSluchanie", 4);
- Download(CategoryParrents[5], "CLPPracaZFilmem", 5);
- Download(CategoryParrents[6], "CLPPracaZIlustracja", 6);
- Download(CategoryParrents[7], "CLPGramatyka", 7);
- Download(CategoryParrents[8], "CLPGry", 8);
- Download(CategoryParrents[9], "CLPTechnologie", 9);
- Download(CategoryParrents[10], "CLPFunkcjeJezykowe", 10);
- Download(CategoryParrents[11], "CLPGadzety", 11);
- Download(CategoryParrents[12], "CLPLodolamacze", 12);
- Download(CategoryParrents[13], "CLPMetodnik", 13);
- }
- public void Download(Transform CategoryParrent, string table, int CategoryNumber)
- {
- string queryString = "select * from " + table + " order by ID";
- int IdeaNumber = 0;
- using (MySqlConnection connection = new MySqlConnection("server=skydomesoftware.cba.pl; password=XXXXXX; user=FridgeCook; database=skydome_software;charset=utf8"))
- {
- MySqlCommand command = new MySqlCommand(queryString, connection);
- if (connection == null)
- {
- connection.Open();
- MySqlDataReader reader = command.ExecuteReader();
- while (reader.Read())
- {
- IdeaNumber++;
- //PrefabIdeaInCategories
- PrefabIdeaInCategories.GetComponent<IdeaButtonName>().ID = int.Parse(reader["ID"].ToString()); //ID
- PrefabIdeaInCategories.GetComponent<IdeaButtonName>().CategoryNumber = CategoryNumber; //Category Number
- PrefabIdeaInCategories.GetComponent<IdeaButtonName>().TextNumber.text = IdeaNumber.ToString();
- PrefabIdeaInCategories.GetComponent<IdeaButtonName>().Title = reader["Title"].ToString(); //Title
- Array.Resize(ref PrefabIdeaInCategories.GetComponent<IdeaButtonName>().ContentPL, 9);
- Array.Resize(ref PrefabIdeaInCategories.GetComponent<IdeaButtonName>().ContentENG, 9);
- for (int i = 0; i <= 8; i++)
- {
- PrefabIdeaInCategories.GetComponent<IdeaButtonName>().ContentPL[i] = reader["ContentPL" + (i + 1)].ToString(); //ContentPL
- PrefabIdeaInCategories.GetComponent<IdeaButtonName>().ContentENG[i] = reader["ContentENG" + (i + 1)].ToString(); //ContentENG
- }
- PrefabIdeaInCategories.GetComponent<IdeaButtonName>().PictureUrl = reader["Picture"].ToString(); //Picture
- Instantiate(PrefabIdeaInCategories, CategoryParrent);
- //PrefabIdeaInCategories
- }
- reader.Close();
- connection.Close();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement