Advertisement
Guest User

Untitled

a guest
May 29th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public static class Utility
  5. {
  6. #region Rotation / Local Rotation
  7. public static void SetRotation(this GameObject go, Quaternion rot)
  8. {
  9. go.transform.rotation = rot;
  10. }
  11.  
  12. public static Quaternion GetRotation(this GameObject go)
  13. {
  14. return go.transform.rotation;
  15. }
  16.  
  17. public static void SetLocalRotation(this GameObject go, Quaternion rot)
  18. {
  19. go.transform.localRotation = rot;
  20. }
  21.  
  22. public static Quaternion GetLocalRotation(this GameObject go)
  23. {
  24. return go.transform.localRotation;
  25. }
  26.  
  27. public static void SetRotation(this Component c, Quaternion rot)
  28. {
  29. c.transform.rotation = rot;
  30. }
  31.  
  32. public static Quaternion GetRotation(this Component c)
  33. {
  34. return c.transform.rotation;
  35. }
  36.  
  37. public static void SetLocalRotation(this Component c, Quaternion rot)
  38. {
  39. c.transform.localRotation = rot;
  40. }
  41.  
  42. public static Quaternion GetLocalRotation(this Component c)
  43. {
  44. return c.transform.localRotation;
  45. }
  46.  
  47. #endregion
  48.  
  49. #region Position
  50. public static void SetPosition(this GameObject go, Vector3 pos)
  51. {
  52. go.transform.position = pos;
  53. }
  54.  
  55. public static Vector3 GetPosition(this GameObject go)
  56. {
  57. return go.transform.position;
  58. }
  59.  
  60. public static void SetPosition(this Component c, Vector3 pos)
  61. {
  62. c.transform.position = pos;
  63. }
  64.  
  65. public static Vector3 GetPosition(this Component c)
  66. {
  67. return c.transform.position;
  68. }
  69. #endregion
  70.  
  71. #region Local position
  72. public static void SetLocalPosition(this GameObject go, Vector3 pos)
  73. {
  74. go.transform.localPosition = pos;
  75. }
  76.  
  77. public static Vector3 GetLocalPosition(this GameObject go)
  78. {
  79. return go.transform.localPosition;
  80. }
  81.  
  82. public static void SetLocalPosition(this Component c, Vector3 pos)
  83. {
  84. c.transform.localPosition = pos;
  85. }
  86.  
  87. public static Vector3 GetLocalPosition(this Component c)
  88. {
  89. return c.transform.localPosition;
  90. }
  91. #endregion
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement