Advertisement
LittleAngel

crash Log 110826 (Offending Script)

Aug 25th, 2011
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.50 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections;
  4.  
  5. [CustomEditor(typeof(MessageManager))]
  6. public class MessageManagerInspector : Editor {
  7.  
  8. public int size = 0;
  9. public bool expanded = true;
  10. public bool[] displaysExpanded = new bool[0];
  11. public MessageManager thisTarget;
  12.  
  13. // The developer can rename any of the field titles here:
  14. public string thisDisplayTitle = "Name: ";
  15. public string messageDisplayTitle = "Message Display: ";
  16. public string defaultColorTitle = "Default Color: ";
  17. public string displayTypeTitle = "Display Type: ";
  18. public string dropShadowTitle = "Drop Shadow: ";
  19. public string dropShadowOffsetTitle = "Drop Shadow Offset: ";
  20. // public string isConstant = false;
  21. public string buildDirection = "Build Direction: ";
  22. public string fadeDelayTitle = "Fade Delay: ";
  23. public string fadeSpeedTitle = "Fade Speed: ";
  24. // public string clip = false;
  25. public string clippingRectTitle = "Clipping Rect: ";
  26. // public string useScrollContainer = false;
  27. // public string pool;
  28. public string poolSizeTitle = "Pool Size: ";
  29.  
  30. void OnEnable () {
  31. thisTarget = target as MessageManager;
  32. size = thisTarget.messageDisplays.Length;
  33. displaysExpanded = new bool[thisTarget.messageDisplays.Length];
  34. for (int i = 0; i < displaysExpanded.Length; i++) {
  35. displaysExpanded[i] = EditorPrefs.GetBool ("FoldFlag"+i);
  36. }
  37. }
  38.  
  39. void OnDisable () {
  40. for (int i = 0; i < displaysExpanded.Length; i++) {
  41. EditorPrefs.SetBool ("FoldFlag"+i, displaysExpanded[i]);
  42. }
  43. }
  44.  
  45. public override void OnInspectorGUI () {
  46. // MessageManager thisTarget = target as MessageManager;
  47.  
  48. EditorGUILayout.BeginHorizontal();
  49. GUILayout.FlexibleSpace();
  50. if (GUILayout.Button ("Expand All")) {
  51. ToggleAllFoldFlags (true);
  52. }
  53. GUILayout.FlexibleSpace();
  54. if (GUILayout.Button ("Collapse All")) {
  55. ToggleAllFoldFlags (false);
  56. }
  57. GUILayout.FlexibleSpace();
  58. EditorGUILayout.EndHorizontal();
  59.  
  60. expanded = EditorGUILayout.Foldout(expanded, "Message Displays");
  61. EditorGUI.indentLevel = 0;
  62. if (expanded) {
  63. EditorGUIUtility.LookLikeInspector();
  64. // EditorGUIUtility.LookLikeControls();
  65. EditorGUI.indentLevel = 1;
  66.  
  67. size = EditorGUILayout.IntField("Size", size);
  68. if (size != thisTarget.messageDisplays.Length) {
  69. ResizeDisplays (thisTarget.messageDisplays.Length, size);
  70. }
  71. for (int i = 0; i < thisTarget.messageDisplays.Length; i++) {
  72. EditorGUI.indentLevel = 2;
  73. string elementName = (!(thisTarget.messageDisplays[i] == null || thisTarget.messageDisplays[i].thisDisplay == "")) ? thisTarget.messageDisplays[i].thisDisplay : "Element " + i;
  74. displaysExpanded[i] = EditorGUILayout.Foldout(displaysExpanded[i], elementName);
  75. if (displaysExpanded[i]) {
  76. EditorGUI.indentLevel = 3;
  77. thisTarget.messageDisplays[i].thisDisplay = EditorGUILayout.TextField (thisDisplayTitle, thisTarget.messageDisplays[i].thisDisplay);
  78. thisTarget.messageDisplays[i].messageDisplay = (SpriteText)EditorGUILayout.ObjectField (messageDisplayTitle, thisTarget.messageDisplays[i].messageDisplay, typeof(SpriteText), true);
  79. thisTarget.messageDisplays[i].defaultColor = EditorGUILayout.ColorField (defaultColorTitle, thisTarget.messageDisplays[i].defaultColor);
  80. thisTarget.messageDisplays[i].displayType = (DisplayType)EditorGUILayout.EnumPopup (displayTypeTitle, thisTarget.messageDisplays[i].displayType);
  81. switch (thisTarget.messageDisplays[i].displayType) {
  82. case DisplayType.Standard:
  83. case DisplayType.Scrolling:
  84. thisTarget.messageDisplays[i].fadeDelay = EditorGUILayout.FloatField (fadeDelayTitle, thisTarget.messageDisplays[i].fadeDelay);
  85. thisTarget.messageDisplays[i].fadeSpeed = EditorGUILayout.FloatField (fadeSpeedTitle, thisTarget.messageDisplays[i].fadeSpeed);
  86. thisTarget.messageDisplays[i].dropShadow = EditorGUILayout.Toggle (dropShadowTitle, thisTarget.messageDisplays[i].dropShadow);
  87. if (thisTarget.messageDisplays[i].dropShadow) {
  88. EditorGUI.indentLevel = 5;
  89. EditorGUIUtility.LookLikeControls();
  90. thisTarget.messageDisplays[i].dropShadowOffset = EditorGUILayout.Vector3Field (dropShadowOffsetTitle, thisTarget.messageDisplays[i].dropShadowOffset);
  91. EditorGUIUtility.LookLikeInspector();
  92. }
  93. break;
  94. case DisplayType.Clipped:
  95. thisTarget.messageDisplays[i].fadeDelay = EditorGUILayout.FloatField (fadeDelayTitle, thisTarget.messageDisplays[i].fadeDelay);
  96. thisTarget.messageDisplays[i].fadeSpeed = EditorGUILayout.FloatField (fadeSpeedTitle, thisTarget.messageDisplays[i].fadeSpeed);
  97. thisTarget.messageDisplays[i].dropShadow = EditorGUILayout.Toggle (dropShadowTitle, thisTarget.messageDisplays[i].dropShadow);
  98. if (thisTarget.messageDisplays[i].dropShadow) {
  99. EditorGUI.indentLevel = 5;
  100. EditorGUIUtility.LookLikeControls();
  101. thisTarget.messageDisplays[i].dropShadowOffset = EditorGUILayout.Vector3Field (dropShadowOffsetTitle, thisTarget.messageDisplays[i].dropShadowOffset);
  102. EditorGUIUtility.LookLikeInspector();
  103. }
  104. EditorGUI.indentLevel = 5;
  105. EditorGUIUtility.LookLikeControls();
  106. thisTarget.messageDisplays[i].clippingRect = EditorGUILayout.RectField (clippingRectTitle, thisTarget.messageDisplays[i].clippingRect);
  107. EditorGUIUtility.LookLikeInspector();
  108. break;
  109. case DisplayType.Pooling:
  110. thisTarget.messageDisplays[i].fadeDelay = EditorGUILayout.FloatField (fadeDelayTitle, thisTarget.messageDisplays[i].fadeDelay);
  111. thisTarget.messageDisplays[i].fadeSpeed = EditorGUILayout.FloatField (fadeSpeedTitle, thisTarget.messageDisplays[i].fadeSpeed);
  112. thisTarget.messageDisplays[i].poolSize = EditorGUILayout.IntField (poolSizeTitle, thisTarget.messageDisplays[i].poolSize);
  113. break;
  114. case DisplayType.Constant:
  115. thisTarget.messageDisplays[i].dropShadow = EditorGUILayout.Toggle (dropShadowTitle, thisTarget.messageDisplays[i].dropShadow);
  116. if (thisTarget.messageDisplays[i].dropShadow) {
  117. EditorGUI.indentLevel = 5;
  118. EditorGUIUtility.LookLikeControls();
  119. thisTarget.messageDisplays[i].dropShadowOffset = EditorGUILayout.Vector3Field (dropShadowOffsetTitle, thisTarget.messageDisplays[i].dropShadowOffset);
  120. EditorGUIUtility.LookLikeInspector();
  121. }
  122. break;
  123. }
  124. }
  125. }
  126. }
  127. }
  128.  
  129. void ToggleAllFoldFlags (bool flag) {
  130. for (int i = 0; i < displaysExpanded.Length; i++) {
  131. displaysExpanded[i] = flag;
  132. }
  133. }
  134.  
  135. void ResizeDisplays (int oldSize, int newSize) {
  136. Debug.Log ("RESIZING");
  137. // MessageManager thisTarget = target as MessageManager;
  138. // MessageDisplay[] newDisplays = new MessageDisplay[newSize];
  139. // for (int i = 0; i < newSize; i++) {
  140. // if (i < oldSize)
  141. // newDisplays[i] = thisTarget.messageDisplays[i];
  142. // else
  143. // newDisplays[i] = new MessageDisplay();
  144. // }
  145. // thisTarget.messageDisplays = newDisplays;
  146. }
  147.  
  148. // public string thisDisplay = "New Display";
  149. // public SpriteText messageDisplay;
  150. // public Color defaultColor = Color.white;
  151. // public DisplayType displayType = DisplayType.Standard;
  152. // public bool dropShadow = true;
  153. // public Vector3 dropShadowOffset = new Vector3 (1.0f, -1.0f, 2.0f);
  154. // public bool isConstant = false;
  155. // public BuildDirection buildDirection;
  156. // public float fadeDelay;
  157. // public float fadeSpeed;
  158. // public bool clip = false;
  159. // public Rect clippingRect;
  160. // public bool useScrollContainer = false;
  161. // public bool pool;
  162. // public int poolSize;
  163. }
  164. /*
  165. asdf a
  166.  
  167. // MyObject.js
  168. public var ElementsExpand : boolean = true;
  169. public var ElementsSize : int = 1;
  170. public var Elements : Transform[] = new Transform[ElementsSize];
  171.  
  172.  
  173. // MyObjectEditor.js -
  174. OnInspectorGUI()
  175. target.ElementsExpand = EditorGUILayout.Foldout(target.ElementsExpand, "Transforms");
  176. if (target.ElementsExpand) {
  177. var x : int = 0;
  178. target.ElementsSize = EditorGUILayout.IntField("Size", target.ElementsSize);
  179. if (target.Elements.length != target.ElementsSize) {
  180. var newArray : Transform[] = new Transform[target.ElementsSize];
  181. for (x = 0; x < target.ElementsSize; x++) {
  182. if (target.Elements.length > x) {
  183. newArray[x] = target.Elements[x];
  184. }
  185. }
  186. target.Elements = newArray;
  187. }
  188. for (x = 0; x < target.Elements.length; x++) {
  189. target.Elements[x] = EditorGUILayout.ObjectField("Element " + x, target.Elements[x], typeof(Transform));
  190. }
  191. }
  192. }
  193.  
  194. -
  195.  
  196.  
  197.  
  198. -
  199. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement