Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions Editor/CubeRandomGen.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}



12 changes: 12 additions & 0 deletions Editor/CubeRandomGen.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.