private static void AddUILayer(UILayer layer, ref GameObjectFinder finder, float z) { var name = System.Enum.GetName(layer.GetType(), layer); var rectTransform = finder.GetComponent <RectTransform>(name); if (rectTransform == null) { Debug.LogErrorFormat("{0} doesn't exist.", layer); return; } FitScreen(rectTransform); _layers[layer] = rectTransform; rectTransform.anchoredPosition3D = new Vector3(0f, 0f, z); }