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 function generate(obj : GameObject, localPath : String) {
- var gridify : GameObject;
- var prefab : Object = PrefabUtility.CreateEmptyPrefab(localPath);
- for (i = 0; i < 10; i++) {
- flippy = !flippy;
- for (j = 0; j < 10; j++) {
- var clone : GameObject = PrefabUtility.InstantiatePrefab (obj) as GameObject;
- if (flippy)
- clone.transform.position = Vector3 (i*1.5, 0, j*1.7272);
- else
- clone.transform.position = Vector3 (i*1.5, 0, j*1.7272 + 0.8636);
- clone.transform.parent = gridify.transform;
- }} PrefabUtility.ReplacePrefab(gridify, prefab, ReplacePrefabOptions.ConnectToPrefab);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement