protected Component(UIGroup uiGroup, Vector2 position, Vector2 size) { // Create a gameobject with the CanvasRenderer component, so we can render as GUI GameObject = new GameObject(); GameObject.AddComponent <CanvasRenderer>(); // Make sure game object persists Object.DontDestroyOnLoad(GameObject); // Create a RectTransform with the desired size _transform = GameObject.AddComponent <RectTransform>(); position = new Vector2( position.x / 1920f, position.y / 1080f ); _transform.anchorMin = _transform.anchorMax = position; _transform.sizeDelta = size; GameObject.transform.SetParent(UIManager.UiGameObject.transform, false); _activeSelf = true; UiGroup = uiGroup; uiGroup?.AddComponent(this); }