Created
July 23, 2021 17:37
-
-
Save kurtdekker/e626e1f06fd5133b4d6951e6e1f3d87b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
// @kurtdekker | |
// Make sure this is in an Editor folder! | |
public static class DuplicationHelpers | |
{ | |
// duplicates the current object and puts it back right after the original. | |
[MenuItem( "Assets/Dupe Here FFS")] | |
static void DupeSelectedItemHereFFS() | |
{ | |
foreach( var item in Selection.gameObjects) | |
{ | |
int siblingOrder = item.transform.GetSiblingIndex(); | |
var originalName = item.name; | |
var copy = GameObject.Instantiate<GameObject>( item, item.transform.parent); | |
// TODO: do anything clever you want with the name, such as suffix it with +1, etc. | |
copy.name = originalName; | |
copy.transform.SetSiblingIndex( siblingOrder + 1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment