Auxiliary.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. public class Auxiliary : MonoBehaviour
  7. {
  8. #region 变量
  9. public string TempString;
  10. public Font TempFont;
  11. public GameObject TempGo;
  12. public List<GameObject> TempGoList;
  13. #endregion
  14. private void Start()
  15. {
  16. }
  17. private void Update()
  18. {
  19. if (Input.GetKeyDown(KeyCode.P))
  20. {
  21. ManaData.Level += 10;
  22. }
  23. }
  24. private void FixedUpdate()
  25. {
  26. }
  27. public static ObjType ToObjType(string str)
  28. {
  29. return (ObjType) Enum.Parse(typeof(ObjType), str);
  30. }
  31. public static void AddSuffix(GameObject go, string value)
  32. {
  33. Transform[] transforms = go.GetComponentsInChildren<Transform>(true);
  34. for (int i = 0; i < transforms.Length; i++)
  35. {
  36. transforms[i].name = transforms[i].name + value;
  37. }
  38. }
  39. public static void AddPrefix(GameObject go, string value)
  40. {
  41. Transform[] transforms = go.GetComponentsInChildren<Transform>(true);
  42. for (int i = 0; i < transforms.Length; i++)
  43. {
  44. transforms[i].name = value + transforms[i].name;
  45. }
  46. }
  47. public static void ChangePrefix(GameObject go, string value)
  48. {
  49. Transform[] transforms = go.GetComponentsInChildren<Transform>(true);
  50. for (int i = 0; i < transforms.Length; i++)
  51. {
  52. int index = transforms[i].name.IndexOf('_');
  53. transforms[i].name = value + transforms[i].name.Remove(0, index);
  54. }
  55. }
  56. public static void ChangeFont(List<GameObject> goList, Font font)
  57. {
  58. for (int j = 0; j < goList.Count; j++)
  59. {
  60. Transform[] transforms = goList[j].GetComponentsInChildren<Transform>(true);
  61. for (int i = 0; i < transforms.Length; i++)
  62. {
  63. Text text = transforms[i].GetComponent<Text>();
  64. TextMesh textMesh = transforms[i].GetComponent<TextMesh>();
  65. if (text != null)
  66. {
  67. text.font = font;
  68. text.fontStyle = FontStyle.Normal;
  69. }
  70. if (textMesh != null)
  71. {
  72. textMesh.font = font;
  73. textMesh.fontStyle = FontStyle.Normal;
  74. }
  75. }
  76. }
  77. }
  78. public static void PrintBounds(GameObject go)
  79. {
  80. Bounds bounds = go.GetComponent<Renderer>().bounds;
  81. Debug.Log(string.Format("x : {0:0.00} y : {1:0.00} z : {2:0.00}", bounds.extents.x, bounds.extents.y, bounds.extents.z));
  82. }
  83. }