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 {
- //DataBase
- static MySqlConnection polaczenie = new MySqlConnection("server=skydomesoftware.cba.pl; password=xxxxxxxxxxxx; user=FridgeCook; database=skydome_software;charset=utf8");
- static MySqlCommand komenda; static MySqlDataReader czytnik;
- static string polecenie = "";
- //DataBase
- 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)
- {
- if (polaczenie.State == System.Data.ConnectionState.Closed) polaczenie.Open();
- {
- polecenie = "select * from "+ table + " order by ID";
- komenda = new MySqlCommand(polecenie, polaczenie);
- komenda.ExecuteNonQuery();
- czytnik = komenda.ExecuteReader();
- int IdeaNumber = 0;
- while (czytnik.Read())
- {
- IdeaNumber++;
- //PrefabIdeaInCategories
- PrefabIdeaInCategories.GetComponent<IdeaButtonName>().ID = int.Parse(czytnik["ID"].ToString()); //ID
- PrefabIdeaInCategories.GetComponent<IdeaButtonName>().CategoryNumber = CategoryNumber; //Category Number
- PrefabIdeaInCategories.GetComponent<IdeaButtonName>().TextNumber.text = IdeaNumber.ToString();
- PrefabIdeaInCategories.GetComponent<IdeaButtonName>().Title = czytnik["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] = czytnik["ContentPL"+(i+1)].ToString(); //ContentPL
- PrefabIdeaInCategories.GetComponent<IdeaButtonName>().ContentENG[i] = czytnik["ContentENG" + (i+1)].ToString(); //ContentENG
- }
- PrefabIdeaInCategories.GetComponent<IdeaButtonName>().PictureUrl = czytnik["Picture"].ToString(); //Picture
- Instantiate(PrefabIdeaInCategories, CategoryParrent);
- //PrefabIdeaInCategories
- }
- czytnik.Close();
- polaczenie.Close();
- }
- }
- }
Add Comment
Please, Sign In to add comment