Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @MenuItem("Level Lord/Gridify")
- static function CreatePrefab() {
- var objs = Selection.gameObjects;
- for (var go : GameObject in objs) {
- var localPath : String = "Assets/Level.prefab";
- generate(go, localPath);
- }
- }
- static var flippy : boolean = false;
- static var outer : GameObject[,];
- static function generate(obj : GameObject, localPath : String) {
- outer = new GameObject[10,10];
- var gridify : GameObject;
- gridify = new GameObject ();
- var prefab : Object = PrefabUtility.CreateEmptyPrefab(localPath);
- for (i = 0; i < 10; i++) {
- flippy = !flippy;
- for (j = 0; j < 10; j++) {
- if (flippy) {
- var clone : GameObject = Instantiate (obj, Vector3 (i*1.5, 0, j*1.7272+0.8636), Quaternion.identity);
- clone.transform.parent = gridify.transform;
- outer[i,j] = clone;
- } else {
- var bob : GameObject = Instantiate (obj, Vector3 (i*1.5, 0, j*1.7272), Quaternion.identity);
- bob.transform.parent = gridify.transform;
- outer[i,j] = bob;
- }}
- } PrefabUtility.ReplacePrefab(gridify, prefab, ReplacePrefabOptions.ConnectToPrefab);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement