CombineInstanceID.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace LunarCatsStudio.SuperCombiner
  5. {
  6. /// <summary>
  7. /// Combine Instance ID
  8. /// </summary>
  9. public class CombineInstanceID
  10. {
  11. // List of combine instances
  12. public List<CombineInstance> _combineInstances = new List<CombineInstance>();
  13. // List of instanceID of every gameObject to combine
  14. public List<int> _instancesID = new List<int>();
  15. // List of name of every gameObject to combine
  16. public List<string> _names = new List<string>();
  17. /// <summary>
  18. /// Add a new Combine Instance
  19. /// </summary>
  20. /// <param name="subMeshIndex"></param>
  21. /// <param name="mesh"></param>
  22. /// <param name="matrix"></param>
  23. /// <param name="instanceID"></param>
  24. /// <param name="name"></param>
  25. public void AddCombineInstance(int subMeshIndex, Mesh mesh, Matrix4x4 matrix, int instanceID, string name)
  26. {
  27. // Add the combine instance
  28. CombineInstance combineInstance = new CombineInstance();
  29. combineInstance.subMeshIndex = subMeshIndex;
  30. combineInstance.mesh = mesh;
  31. combineInstance.transform = matrix;
  32. _combineInstances.Add(combineInstance);
  33. // Add the instanceID
  34. _instancesID.Add(instanceID);
  35. // Add the name
  36. _names.Add(name);
  37. }
  38. public void AddRange(CombineInstanceID instances)
  39. {
  40. _combineInstances.AddRange(instances._combineInstances);
  41. _instancesID.AddRange(instances._instancesID);
  42. _names.AddRange(instances._names);
  43. }
  44. /// <summary>
  45. /// Clear data
  46. /// </summary>
  47. public void Clear()
  48. {
  49. _combineInstances.Clear();
  50. _instancesID.Clear();
  51. _names.Clear();
  52. }
  53. /// <summary>
  54. /// Return the number of _combineInstances instances
  55. /// </summary>
  56. /// <returns></returns>
  57. public int Count()
  58. {
  59. return _combineInstances.Count;
  60. }
  61. }
  62. }