cwisbg

ListTestCopy

Jan 4th, 2019
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class ListTestCopy : MonoBehaviour {
  6. public int MaxListLen = 1000;
  7. public float NewFloat = 0.0f;
  8. public Vector3 NewVector = Vector3.zero;
  9. private List<QuadTreeObject> QuadList = new List<QuadTreeObject>();
  10. private DoQuadListUpdate ListUpdater = new DoQuadListUpdate();
  11.  
  12. class QuadTreeObject
  13. {
  14. public QuadTreeObject(QuadTreeObject lastQuad)
  15. {
  16. FloatTest = lastQuad.FloatTest;
  17. VectorTest = lastQuad.VectorTest;
  18. }
  19. public QuadTreeObject(Vector3 NewVectorTest)
  20. {
  21. VectorTest = NewVectorTest;
  22. }
  23. public float FloatTest = new float();
  24. public Vector3 VectorTest = new Vector3();
  25. }
  26.  
  27. class DoQuadListUpdate
  28. {
  29. public List<QuadTreeObject> CopyQuadList(List<QuadTreeObject> ToCopyList)
  30. {
  31. List<QuadTreeObject> CopiedList = new List<QuadTreeObject>();
  32. foreach (QuadTreeObject ToCopyObj in ToCopyList)
  33. {
  34. QuadTreeObject CopiedObj = new QuadTreeObject(ToCopyObj);
  35. Debug.Log("HERE");
  36. CopiedList.Add(CopiedObj);
  37. }
  38. return CopiedList;
  39. }
  40. }
  41.  
  42. void Update ()
  43. {
  44. for (int i = 0; i < 100; i++)
  45. {
  46. DoQuadListUpdate ListUpdater = new DoQuadListUpdate();
  47. List<QuadTreeObject> QuadList = new List<QuadTreeObject>();
  48. for (int ii = 0; ii < MaxListLen; ii++)
  49. {
  50. QuadTreeObject NewQuadObj = new QuadTreeObject(NewVector);
  51. QuadList.Add(NewQuadObj);
  52. }
  53. List<QuadTreeObject> CurrentList = new List<QuadTreeObject>();
  54. CurrentList = ListUpdater.CopyQuadList(QuadList);
  55.  
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment