using System; using System.Collections.Generic; using Unity.UIWidgets.foundation; using UnityEngine; namespace UIWidgetsSample.RaycastableScene { public class ObjectItem { public GameObject obj; public Vector3 position; public string name; } public class GameObjectManager : MonoBehaviour { public GameObject cube; public GameObject ball; public GameObject cylinder; public Transform center; public static Transform centerInstance; public static Dictionary objects = new Dictionary(); // public static List closeObjects = new List(); public Vector3 NewPosition() { int count = objects.Count; int sq = (int) Mathf.Sqrt(count); int remain = count - sq * sq; int r = 0; int c = 0; if (remain <= sq) { r = sq; c = remain; } else { r = 2 * sq - remain; c = sq; } var s = 2; return center.position + new Vector3(r * s, c * s, 0); } public void CreateGameObject(GameObject obj, int count, string name) { int sq = (int)Mathf.Sqrt(count); if (obj) { for (int i = 0; i