diff --git a/Editor/CubeRandomGen.cs b/Editor/CubeRandomGen.cs new file mode 100644 index 0000000..36bca2e --- /dev/null +++ b/Editor/CubeRandomGen.cs @@ -0,0 +1,46 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +[ExecuteInEditMode] +class RandomGenWindow : EditorWindow { + Object spawnableObject; + Object targetCube; + int numberOfEncryptions = 1; + + [MenuItem ("Tools/Random Encryption Placer")] + + public static void ShowWindow () { + EditorWindow.GetWindow(typeof(RandomGenWindow)); + } + + void OnGUI () { + GUILayout.Label ("Base Settings", EditorStyles.boldLabel); + spawnableObject = EditorGUILayout.ObjectField("Object to Clone:", spawnableObject, typeof(GameObject), true); + targetCube = EditorGUILayout.ObjectField("Target Cube:", targetCube, typeof(GameObject), true); + numberOfEncryptions = EditorGUILayout.IntSlider("Object Count:", numberOfEncryptions, 1, 100); + if (GUILayout.Button("Spawn Objects")) { +/// if (spawnableObject == null) +/// this.ShowNotification(GUIContent("No spawnable object selected.")); +/// else if (targetCube == null) +/// this.showNotification(GUIContent("No target cube selected")); +/// else + { + for (int i = 0; i < numberOfEncryptions; i++) + { + spawnObject((GameObject)spawnableObject, (GameObject)targetCube); + } + } + } + } + + public void spawnObject(GameObject spawnableThing, GameObject targetLocation) + { + Vector3 rndPosWithin; + rndPosWithin = targetLocation.transform.TransformPoint(Random.Range(-1f, 1f) * .5f, Random.Range(-1f, 1f) * .5f, Random.Range(-1f, 1f) * .5f); + Instantiate(spawnableThing, rndPosWithin, targetLocation.transform.rotation); + } +} + + + diff --git a/Editor/CubeRandomGen.cs.meta b/Editor/CubeRandomGen.cs.meta new file mode 100644 index 0000000..d98a810 --- /dev/null +++ b/Editor/CubeRandomGen.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6c690b6a07b935842be5d926616e68f4 +timeCreated: 1626026775 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: