SuperCombinerSettings.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. using System;
  2. using UnityEngine;
  3. using System.Collections.Generic;
  4. namespace LunarCatsStudio.SuperCombiner
  5. {
  6. [Serializable]
  7. public class GeneralSettings
  8. {
  9. public const string DEFAULT_SESSION_NAME = "combinedSession";
  10. public const string DEFAULT_VERSION_NUMBER = "UNKNOWN";
  11. string _version_number = DEFAULT_VERSION_NUMBER;
  12. string _session_name = DEFAULT_SESSION_NAME;
  13. bool _combine_at_runtime = false;
  14. GameObject _target_game_object = null;
  15. public string versionNumber
  16. {
  17. get { return _version_number; }
  18. set
  19. {
  20. if (value.Length <= 0)
  21. value = DEFAULT_VERSION_NUMBER;
  22. if (value != _version_number)
  23. _version_number = value;
  24. }
  25. }
  26. public string sessionName
  27. {
  28. get { return _session_name; }
  29. set
  30. {
  31. if (value.Length <= 0)
  32. value = DEFAULT_SESSION_NAME;
  33. if (value != _session_name)
  34. _session_name = value;
  35. }
  36. }
  37. public bool combineAtRuntime
  38. {
  39. get { return _combine_at_runtime; }
  40. set
  41. {
  42. if (value != _combine_at_runtime)
  43. _combine_at_runtime = value;
  44. }
  45. }
  46. public GameObject targetGameObject
  47. {
  48. get { return _target_game_object; }
  49. set
  50. {
  51. if (value != _target_game_object)
  52. _target_game_object = value;
  53. }
  54. }
  55. }
  56. [Serializable]
  57. public class TextureSettings
  58. {
  59. [HideInInspector]
  60. public List<int> textureAtlasSizesValues = new List<int>() {
  61. 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192
  62. };
  63. public List<string> textureAtlasSizesLabels = new List<string>() {
  64. "32", "64", "128", "256", "512", "1024", "2048", "4096", "8192"
  65. };
  66. public const float MIN_TILING_FACTOR = 1f;
  67. public const float MAX_TILING_FACTOR = 2f;
  68. private int _atlas_size = 1024;
  69. [Range(MIN_TILING_FACTOR, MAX_TILING_FACTOR)] private float _tiling_factor = 1f;
  70. private int _padding = 0;
  71. public int atlasSize
  72. {
  73. get { return _atlas_size; }
  74. set
  75. {
  76. if (value != _atlas_size && textureAtlasSizesValues.IndexOf(value) >= 0)
  77. _atlas_size = value;
  78. }
  79. }
  80. public float tilingFactor
  81. {
  82. get { return _tiling_factor; }
  83. set
  84. {
  85. if (value != _tiling_factor)
  86. _tiling_factor = value;
  87. }
  88. }
  89. public int padding
  90. {
  91. get { return _padding; }
  92. set
  93. {
  94. if (value != _padding)
  95. _padding = value;
  96. }
  97. }
  98. }
  99. [Serializable]
  100. public class MaterialSettings
  101. {
  102. private bool _multipleMaterialsMode = false;
  103. private bool _combineEachGroupAsSubmesh = false;
  104. public List<Material> multiMaterials0 = new List<Material>();
  105. public List<Material> multiMaterials1 = new List<Material>();
  106. public List<Material> multiMaterials2 = new List<Material>();
  107. public List<Material> multiMaterials3 = new List<Material>();
  108. public List<Material> multiMaterials4 = new List<Material>();
  109. public List<Material> multiMaterials5 = new List<Material>();
  110. public List<Material> multiMaterials6 = new List<Material>();
  111. public List<Material> multiMaterials7 = new List<Material>();
  112. public List<Material> multiMaterials8 = new List<Material>();
  113. public List<Material> multiMaterials9 = new List<Material>();
  114. public List<Material> multiMaterials10 = new List<Material>();
  115. private int _multiple_materials_count = 0;
  116. public List<string> _customShaderProperties;
  117. // Getter/Setter
  118. public bool combineEachGroupAsSubmesh
  119. {
  120. get => _combineEachGroupAsSubmesh;
  121. set => _combineEachGroupAsSubmesh = value;
  122. }
  123. public int multipleMaterialsCount
  124. {
  125. get { return _multiple_materials_count; }
  126. set
  127. {
  128. if (value != _multiple_materials_count)
  129. _multiple_materials_count = value;
  130. }
  131. }
  132. public List<string> customShaderProperties
  133. {
  134. get { return _customShaderProperties; }
  135. set
  136. {
  137. if (value != _customShaderProperties)
  138. _customShaderProperties = value;
  139. }
  140. }
  141. public bool multipleMaterialsMode
  142. {
  143. get { return _multipleMaterialsMode; }
  144. set
  145. {
  146. if (value != _multipleMaterialsMode)
  147. _multipleMaterialsMode = value;
  148. }
  149. }
  150. }
  151. [Serializable]
  152. public class MeshSettings
  153. {
  154. public const int MIN_MESHS = 0;
  155. public const int MAX_MESHS = 65534;
  156. public enum MeshOutputType
  157. {
  158. Mesh = 0,
  159. SkinnedMesh = 1
  160. };
  161. bool _manage_lods = false;
  162. int _managed_lod_level = 0;
  163. bool _combine_meshs = false;
  164. bool _generate_uv2 = true;
  165. bool _manageColliders = false;
  166. GameObject _targetGameObject = null;
  167. MeshOutputType _mesh_output = MeshOutputType.Mesh;
  168. public int managedLODLevel
  169. {
  170. get { return _managed_lod_level; }
  171. set
  172. {
  173. if (value != _managed_lod_level)
  174. _managed_lod_level = value;
  175. }
  176. }
  177. public bool manageLODs
  178. {
  179. get { return _manage_lods; }
  180. set
  181. {
  182. if (value != _manage_lods)
  183. _manage_lods = value;
  184. }
  185. }
  186. public bool manageColliders
  187. {
  188. get { return _manageColliders; }
  189. set
  190. {
  191. if (value != _manageColliders)
  192. _manageColliders = value;
  193. }
  194. }
  195. public GameObject targetGameObject
  196. {
  197. get { return _targetGameObject; }
  198. set
  199. {
  200. if (value != _targetGameObject)
  201. _targetGameObject = value;
  202. }
  203. }
  204. public bool combineMeshs
  205. {
  206. get { return _combine_meshs; }
  207. set
  208. {
  209. if (value != _combine_meshs)
  210. _combine_meshs = value;
  211. }
  212. }
  213. public bool generateUv2
  214. {
  215. get { return _generate_uv2; }
  216. set
  217. {
  218. if (value != _generate_uv2)
  219. _generate_uv2 = value;
  220. }
  221. }
  222. public MeshOutputType meshOutputType
  223. {
  224. get { return _mesh_output; }
  225. set
  226. {
  227. if (value != _mesh_output)
  228. _mesh_output = value;
  229. }
  230. }
  231. }
  232. //[CreateAssetMenu(menuName = "SuperCombiner/New Settings", fileName = "New_SuperCombiner_Settings.asset")]
  233. public class SuperCombinerSettings : ScriptableObject
  234. {
  235. GeneralSettings _general_settings;
  236. TextureSettings _texture_settings;
  237. public MaterialSettings _material_settings; // Needs to be public so that SuperCOmbinerSettingsEditor can access the propertyField
  238. MeshSettings _mesh_settings;
  239. public SuperCombinerSettings()
  240. {
  241. _general_settings = new GeneralSettings();
  242. _texture_settings = new TextureSettings();
  243. _material_settings = new MaterialSettings();
  244. _mesh_settings = new MeshSettings();
  245. }
  246. public GeneralSettings generalSettings
  247. {
  248. get { return _general_settings; }
  249. set
  250. {
  251. if (value != _general_settings)
  252. _general_settings = value;
  253. }
  254. }
  255. public TextureSettings textureSettings
  256. {
  257. get { return _texture_settings; }
  258. set
  259. {
  260. if (value != _texture_settings)
  261. _texture_settings = value;
  262. }
  263. }
  264. public MaterialSettings materialSettings
  265. {
  266. get { return _material_settings; }
  267. set
  268. {
  269. if (value != _material_settings)
  270. _material_settings = value;
  271. }
  272. }
  273. public MeshSettings meshSettings
  274. {
  275. get { return _mesh_settings; }
  276. set
  277. {
  278. if (value != _mesh_settings)
  279. _mesh_settings = value;
  280. }
  281. }
  282. }
  283. }