Skip to content

Instantly share code, notes, and snippets.

@KenneyNL
Last active June 23, 2022 19:41
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save KenneyNL/62a9e986b55c6b12796d25ea74425718 to your computer and use it in GitHub Desktop.
Save KenneyNL/62a9e986b55c6b12796d25ea74425718 to your computer and use it in GitHub Desktop.
Circular menu sample code for Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CircularMenu : MonoBehaviour{
public float radius = 100.0f;
public float offset = 0.0f;
void Start(){
for(int i = 0; i < transform.childCount; i++){
float angle = i * (Mathf.PI * 2f) / transform.childCount;
transform.GetChild(i).localPosition = new Vector3(Mathf.Cos(offset + angle) * radius, Mathf.Sin(offset + angle) * radius, 0);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment