Skip to content

Instantly share code, notes, and snippets.

@giacomelli
Created June 11, 2019 23:52
Show Gist options
  • Save giacomelli/3c05b37b9af2ec6cfef0db58a2e5e3a7 to your computer and use it in GitHub Desktop.
Save giacomelli/3c05b37b9af2ec6cfef0db58a2e5e3a7 to your computer and use it in GitHub Desktop.
#unitytips: MenuItem "CONTEXT/<component>" - http://diegogiacomelli.com.br/unitytips-menuitem-context-component
using UnityEditor;
using UnityEngine;
public static class TransformContextMenu
{
[MenuItem("CONTEXT/Transform/Make a circle")]
public static void MakeCircle()
{
var length = Selection.gameObjects.Length;
var radius = 5;
for (int i = 0; i < length; i++)
{
var angle = i * Mathf.PI * 2 / length;
Selection.gameObjects[i].transform.position = new Vector3(Mathf.Cos(angle), 0, Mathf.Sin(angle)) * radius;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment