Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEditor;
- public class MoveObjectsInDirections : EditorWindow
- {
- public Vector2 newValues;
- [MenuItem("MyScripts/Move Objects")]
- private static void ShowEditor() {
- EditorWindow.GetWindow<MoveObjectsInDirections>(false, "Move Objects");
- }
- private void OnGUI() {
- GUILayout.BeginVertical("box");
- EditorGUILayout.HelpBox("All Selected objects in the Hierarchy will be moved.", MessageType.Info);
- if (GUILayout.Button("Move Positions")) {
- if (Selection.transforms.Length > 0) {
- for (int i = 0; i < Selection.gameObjects.Length; ++i) {
- Selection.gameObjects[i].transform.localPosition = new Vector2(Selection.gameObjects[i].transform.localPosition.x + newValues.x, Selection.gameObjects[i].transform.localPosition.y + newValues.y);
- }
- }
- }
- newValues = EditorGUILayout.Vector2Field("Vector", newValues);
- GUILayout.EndVertical();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment