CustomizeItemData.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5. using Newtonsoft;
  6. using Newtonsoft.Json;
  7. namespace DataTools
  8. {
  9. [System.Serializable]
  10. public class SerializableColor
  11. {
  12. public float R;
  13. public float G;
  14. public float B;
  15. public float A;
  16. public SerializableColor(Color32 color)
  17. {
  18. R = color.r;
  19. G = color.g;
  20. B = color.b;
  21. A = color.a;
  22. }
  23. public Color32 GetColor()
  24. {
  25. return new Color(R, G, B, A);
  26. }
  27. public static implicit operator SerializableColor(Color32 v)
  28. {
  29. return new SerializableColor(v);
  30. }
  31. }
  32. [Serializable]
  33. public class CustomizeItemData
  34. {
  35. [SerializeField]
  36. [JsonProperty]
  37. private string subCategoryId;
  38. [SerializeField]
  39. [JsonProperty]
  40. private string itemId;
  41. [SerializeField]
  42. [JsonProperty]
  43. //private SerializableColor color32;
  44. private Color32 color32;
  45. public CustomizeItemData(string subcategoryid, string itemid, Color32 color32)
  46. {
  47. this.subCategoryId = subcategoryid;
  48. this.itemId = itemid;
  49. this.color32 = color32;//new SerializableColor(color);
  50. }
  51. [JsonIgnore]
  52. public string SubCategoryId
  53. {
  54. get
  55. {
  56. return subCategoryId;
  57. }
  58. set
  59. {
  60. subCategoryId = value;
  61. }
  62. }
  63. [JsonIgnore]
  64. public string ItemId
  65. {
  66. get
  67. {
  68. return itemId;
  69. }
  70. set
  71. {
  72. itemId = value;
  73. }
  74. }
  75. [JsonIgnore]
  76. public Color32 Color32
  77. {
  78. get
  79. {
  80. //return color32;
  81. return color32/*.GetColor()*/;
  82. }
  83. set
  84. {
  85. color32 = value;
  86. }
  87. }
  88. }
  89. }