Program.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.CompilerServices;
  4. [assembly: InternalsVisibleTo("MBansheeEditor")]
  5. namespace BansheeEngine
  6. {
  7. class Program
  8. {
  9. static void Main()
  10. {
  11. //SceneObject otherSO = new SceneObject("OtherSO");
  12. //DbgComponent2 dbgComponent2 = otherSO.AddComponent<DbgComponent2>();
  13. //dbgComponent2.a2 = 33;
  14. //GUIElementStateStyle dbgStyle = new GUIElementStateStyle();
  15. //SceneObject so = new SceneObject("TestSO");
  16. //DbgComponent dbgComponent = so.AddComponent<DbgComponent>();
  17. //dbgComponent.a = 5;
  18. //dbgComponent.b = "SomeTestVal";
  19. //dbgComponent.complex.someValue = 19;
  20. //dbgComponent.complex.anotherValue = "AnotherValue";
  21. //dbgComponent.complex2.someValue2 = 21;
  22. //dbgComponent.complex2.anotherValue2 = "AnotherValue2";
  23. //dbgComponent.arrA = new int[5];
  24. //dbgComponent.arrA[4] = 5;
  25. //dbgComponent.arrB = new string[5];
  26. //dbgComponent.arrB[4] = "ArrAnotherValue";
  27. //dbgComponent.arrComplex = new DbgSerzObj[5];
  28. //dbgComponent.arrComplex[4].someValue = 99;
  29. //dbgComponent.arrComplex[4].anotherValue = "ArrComplexAnotherValue";
  30. //dbgComponent.arrComplex2 = new DbgSerzCls[5];
  31. //dbgComponent.arrComplex2[4] = new DbgSerzCls();
  32. //dbgComponent.arrComplex2[4].someValue2 = 101;
  33. //dbgComponent.arrComplex2[4].anotherValue2 = "ArrComplex2AnotherValue";
  34. //dbgComponent.listA = new List<int>();
  35. //dbgComponent.listA.Add(5);
  36. //dbgComponent.listB = new List<string>();
  37. //dbgComponent.listB.Add("ListAnotherValue");
  38. //dbgComponent.listB.Add(null);
  39. //dbgComponent.listComplex = new List<DbgSerzObj>();
  40. //dbgComponent.listComplex.Add(new DbgSerzObj());
  41. //dbgComponent.listComplex.Add(new DbgSerzObj(99, "ListComplexAnotherValue"));
  42. //dbgComponent.listComplex2 = new List<DbgSerzCls>();
  43. //dbgComponent.listComplex2.Add(new DbgSerzCls());
  44. //dbgComponent.listComplex2[0].someValue2 = 101;
  45. //dbgComponent.listComplex2[0].anotherValue2 = "ListComplexAnotherValue";
  46. //dbgComponent.listComplex2.Add(null);
  47. //dbgComponent.otherComponent = dbgComponent2;
  48. //dbgComponent.otherSO = otherSO;
  49. //dbgComponent.zeArray = new int[5][][];
  50. //dbgComponent.zeList = new List<DbgSerzObj>();
  51. //dbgComponent.zeDict = new Dictionary<string, int>();
  52. //dbgComponent.zeList.Add(new DbgSerzObj());
  53. //dbgComponent.zeList.Add(new DbgSerzObj());
  54. //dbgComponent.zeList.Add(new DbgSerzObj(101, ""));
  55. //dbgComponent.zeList.Add(new DbgSerzObj());
  56. //dbgComponent.zeDict["supSup"] = 10001;
  57. //dbgComponent.zeDict["lolz"] = 696969;
  58. //var enumerator = dbgComponent.zeDict.GetEnumerator();
  59. //int all = 0;
  60. //while (enumerator.MoveNext())
  61. //{
  62. // all += enumerator.Current.Value;
  63. //}
  64. //for (int i = 0; i < dbgComponent.zeArray.Length; i++)
  65. //{
  66. // dbgComponent.zeArray[i] = new int[6][];
  67. // for (int j = 0; j < dbgComponent.zeArray[i].Length; j++)
  68. // dbgComponent.zeArray[i][j] = new int[7];
  69. //}
  70. //dbgComponent.zeArray[4][1][3] = 129;
  71. //dbgTestComponentClone(so);
  72. //for (int i = 0; i < so.GetNumChildren(); i++)
  73. //{
  74. // SceneObject childSO = so.GetChild(i);
  75. // DbgComponent otherComponent = childSO.GetComponent<DbgComponent>();
  76. // reportDbgValue(otherComponent.a, otherComponent.b, otherComponent.complex.someValue,
  77. // otherComponent.complex2.anotherValue2);
  78. // reportDbgValue(otherComponent.arrA[4], otherComponent.arrB[4], otherComponent.arrComplex[4].someValue,
  79. // otherComponent.arrComplex2[4].anotherValue2);
  80. // reportDbgValue(otherComponent.listA[0], otherComponent.listB[0], otherComponent.listComplex[1].someValue,
  81. // otherComponent.listComplex2[0].anotherValue2);
  82. // //reportDbgValue(childSO.GetComponent<DbgComponent>().zeDict["lolz"], childSO.GetComponent<DbgComponent>().zeList[2].someValue, childSO.GetComponent<DbgComponent>().zeArray[4][1][3], typeof(DbgComponent));
  83. //}
  84. //Color newColor = Color.red;
  85. //dbgStyle.textColor = newColor;
  86. //Color myColor = dbgStyle.textColor;
  87. //dbgStyle.textColor = myColor;
  88. SerializableObject obj = new SerializableObject(typeof(DbgSerzCls), new DbgSerzCls());
  89. Debug.Log(obj.fields.Length);
  90. for (int i = 0; i < obj.fields.Length; i++)
  91. {
  92. Debug.Log(i + ". " + obj.fields[i].Name + " - " + obj.fields[i].Type.ToString());
  93. }
  94. SerializableProperty prop = obj.fields[0].GetProperty();
  95. Debug.Log("Old value: " + prop.GetValue<int>());
  96. prop.SetValue<int>(33);
  97. Debug.Log("New value: " + prop.GetValue<int>());
  98. SerializableProperty prop2 = obj.fields[2].GetProperty();
  99. Debug.Log("Old value: " + (prop2.GetValue<DbgSerzCls>() == null));
  100. DbgSerzCls child = new DbgSerzCls();
  101. child.anotherValue2 = "ass";
  102. prop2.SetValue<DbgSerzCls>(child);
  103. if (prop2.GetValue<DbgSerzCls>() == null)
  104. Debug.Log("New value: null");
  105. else
  106. Debug.Log("New value: " + prop2.GetValue<DbgSerzCls>().anotherValue2);
  107. }
  108. [MethodImpl(MethodImplOptions.InternalCall)]
  109. private static extern void dbgTestComponentClone(SceneObject so);
  110. [MethodImpl(MethodImplOptions.InternalCall)]
  111. private static extern void reportDbgValue(int a, string b, int a2, string b2);
  112. }
  113. }