rabidus-test/Assets/PlaceObjectsInCircle.cs

28 lines
695 B
C#
Raw Permalink Normal View History

2023-10-02 19:12:35 +03:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlaceObjectsInCircle : MonoBehaviour
{
public float Distance;
[ContextMenu("Place")]
public void Place()
{
List<Transform> children = new List<Transform>();
for (int i = 0; i < transform.childCount; i++)
{
children.Add(transform.GetChild(i));
}
for (int i = 0; i < children.Count; i++)
{
children[i].transform.rotation = Quaternion.Euler(new Vector3(-90, i * (360f / children.Count), 0));
children[i].transform.localPosition = Vector3.zero + children[i].transform.up * Distance;
}
}
}