Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. using UnityEditor;
  2. using UnityEngine.UI;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5. using static UnityEngine.GraphicsBuffer;
  6.  
  7. public class VisualNovelHelper : EditorWindow
  8. {
  9. public Sprite someSprite;
  10. Color color;
  11. GameObject gameObject;
  12. private SpriteRenderer spriteR;
  13. [CustomEditor(typeof(NewWindow))]
  14. public GameObject[] FogTypes;
  15. float speed = 100f;
  16. public int gamer;
  17. private Sprite someSpriteHere;
  18.  
  19. // Update is called once per frame
  20. void Update()
  21. {
  22.  
  23. }
  24. [MenuItem("Window/Basics")]
  25.  
  26. public static void ShowWindow()
  27. {
  28. EditorWindow.GetWindow<VisualNovelHelper>("Commonly Used Functions");
  29. }
  30.  
  31. [MenuItem("GameObject/2D Object/CreateGameObjects")]
  32. void OnGUI()
  33. {
  34.  
  35. GUILayout.Label("Generic Functions", EditorStyles.boldLabel);
  36.  
  37. color = EditorGUILayout.ColorField("Color", color);
  38. if (GUILayout.Button("Reload Scene"))
  39. {
  40.  
  41. SceneManager.LoadScene(SceneManager.GetActiveScene().name);
  42. }
  43. if (GUILayout.Button("Colorize Objects"))
  44. {
  45. Colorize();
  46. }
  47. if (GUILayout.Button("Add A Collider to selected Objects"))
  48. {
  49. Colliderize();
  50. }
  51. if (GUILayout.Button("Higher In Layer"))
  52. {
  53.  
  54. foreach (GameObject obj in Selection.gameObjects)
  55. {
  56.  
  57.  
  58. obj.GetComponent<SpriteRenderer>().sortingOrder += 1;
  59. }
  60. }
  61. if (GUILayout.Button("Lower In Layer"))
  62. {
  63.  
  64. foreach (GameObject obj in Selection.gameObjects)
  65. {
  66.  
  67. obj.GetComponent<SpriteRenderer>().sortingOrder -= 1;
  68. }
  69. }
  70. if (GUILayout.Button("Set Selected Objects On"))
  71. {
  72.  
  73. foreach (GameObject obj in Selection.gameObjects)
  74. {
  75.  
  76. obj.SetActive(true);
  77. }
  78. }
  79. if (GUILayout.Button("Set Selected Objects Off"))
  80. {
  81.  
  82. foreach (GameObject obj in Selection.gameObjects)
  83. {
  84.  
  85. obj.SetActive(false);
  86. }
  87. }
  88.  
  89. if (GUILayout.Button("Add a new environment textbox"))
  90. {
  91.  
  92.  
  93. GameObject go = new GameObject("MyCreatedGO");
  94. SpriteRenderer renderer = go.AddComponent<SpriteRenderer>();
  95. renderer.sprite = someSpriteHere;
  96. go.transform.position = new Vector3(0, 0, 0);
  97.  
  98. }
  99. GUILayout.Label("Cautionary Tape Cautionary Tape Cautionary Tape", EditorStyles.boldLabel);
  100. if (GUILayout.Button("Delete All Selected Objects"))
  101. {
  102.  
  103. foreach (GameObject obj in Selection.gameObjects)
  104. {
  105.  
  106. DestroyImmediate(obj);
  107.  
  108. }
  109. }
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119. void Colorize()
  120. {
  121. foreach (GameObject obj in Selection.gameObjects)
  122. {
  123. Renderer renderer = obj.GetComponent<Renderer>();
  124.  
  125. if (renderer != null)
  126. {
  127. renderer.sharedMaterial.color = color;
  128. }
  129.  
  130. }
  131. }
  132. void Colliderize()
  133. {
  134. foreach (GameObject obj in Selection.gameObjects)
  135. {
  136.  
  137. obj.AddComponent<BoxCollider2D>();
  138.  
  139. }
  140. }
  141.  
  142. }
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement