Advertisement
Guest User

Untitled

a guest
Aug 11th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using MySql.Data.MySqlClient;
  4. using System;
  5. using UnityEngine.UI;
  6. using TMPro;
  7.  
  8. public class DownloadIdeas : MonoBehaviour
  9. {
  10.  
  11.  
  12.  
  13.  
  14. public GameObject PrefabIdeaInCategories;
  15.  
  16.  
  17. public Transform[] CategoryParrents;
  18.  
  19. private void Start()
  20. {
  21. MainFunction();
  22. }
  23.  
  24. public void MainFunction()
  25. {
  26. Download(CategoryParrents[0], "CLPKonwersacje", 0);
  27.  
  28. Download(CategoryParrents[1], "CLPSlownictwo", 1);
  29.  
  30. Download(CategoryParrents[2], "CLPPisanie", 2);
  31.  
  32. Download(CategoryParrents[3], "CLPPracaZTekstem", 3);
  33.  
  34. Download(CategoryParrents[4], "CLPSluchanie", 4);
  35.  
  36. Download(CategoryParrents[5], "CLPPracaZFilmem", 5);
  37.  
  38. Download(CategoryParrents[6], "CLPPracaZIlustracja", 6);
  39.  
  40. Download(CategoryParrents[7], "CLPGramatyka", 7);
  41.  
  42. Download(CategoryParrents[8], "CLPGry", 8);
  43.  
  44. Download(CategoryParrents[9], "CLPTechnologie", 9);
  45.  
  46. Download(CategoryParrents[10], "CLPFunkcjeJezykowe", 10);
  47.  
  48. Download(CategoryParrents[11], "CLPGadzety", 11);
  49.  
  50. Download(CategoryParrents[12], "CLPLodolamacze", 12);
  51.  
  52. Download(CategoryParrents[13], "CLPMetodnik", 13);
  53.  
  54. }
  55.  
  56. public void Download(Transform CategoryParrent, string table, int CategoryNumber)
  57. {
  58.  
  59. string queryString = "select * from " + table + " order by ID";
  60. int IdeaNumber = 0;
  61.  
  62. using (MySqlConnection connection = new MySqlConnection("server=skydomesoftware.cba.pl; password=XXXXXX; user=FridgeCook; database=skydome_software;charset=utf8"))
  63. {
  64. MySqlCommand command = new MySqlCommand(queryString, connection);
  65.  
  66. if (connection == null)
  67. {
  68. connection.Open();
  69. MySqlDataReader reader = command.ExecuteReader();
  70.  
  71.  
  72. while (reader.Read())
  73. {
  74. IdeaNumber++;
  75.  
  76. //PrefabIdeaInCategories
  77. PrefabIdeaInCategories.GetComponent<IdeaButtonName>().ID = int.Parse(reader["ID"].ToString()); //ID
  78. PrefabIdeaInCategories.GetComponent<IdeaButtonName>().CategoryNumber = CategoryNumber; //Category Number
  79. PrefabIdeaInCategories.GetComponent<IdeaButtonName>().TextNumber.text = IdeaNumber.ToString();
  80. PrefabIdeaInCategories.GetComponent<IdeaButtonName>().Title = reader["Title"].ToString(); //Title
  81. Array.Resize(ref PrefabIdeaInCategories.GetComponent<IdeaButtonName>().ContentPL, 9);
  82. Array.Resize(ref PrefabIdeaInCategories.GetComponent<IdeaButtonName>().ContentENG, 9);
  83. for (int i = 0; i <= 8; i++)
  84. {
  85. PrefabIdeaInCategories.GetComponent<IdeaButtonName>().ContentPL[i] = reader["ContentPL" + (i + 1)].ToString(); //ContentPL
  86. PrefabIdeaInCategories.GetComponent<IdeaButtonName>().ContentENG[i] = reader["ContentENG" + (i + 1)].ToString(); //ContentENG
  87. }
  88. PrefabIdeaInCategories.GetComponent<IdeaButtonName>().PictureUrl = reader["Picture"].ToString(); //Picture
  89. Instantiate(PrefabIdeaInCategories, CategoryParrent);
  90. //PrefabIdeaInCategories
  91. }
  92. reader.Close();
  93. connection.Close();
  94. }
  95. }
  96. }
  97.  
  98.  
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement