public static Vector2 GetScreenCenter() { GameObject canvasObject = RectCanvas.GetCanvasObject(); RectTransform canvasTransformComponent = canvasObject.GetComponent <RectTransform>(); return(new Vector2(canvasTransformComponent.pivot.x - Screen.width / 2, canvasTransformComponent.pivot.y + Screen.height / 2)); }
protected static GameObject Init() { GameObject canvas = RectCanvas.GetCanvasObject(); GameObject messageBoxObject = new GameObject("Message Box"); messageBoxObject.transform.SetParent(canvas.transform); messageBoxObject.AddComponent <RectMessageBox>(); return(messageBoxObject); }
private static void CreateGuiCursor() { GameObject canvas = RectCanvas.GetCanvasObject(); float xPos = Screen.width / 2 - (cursorSize / 2); float yPos = Screen.height / 2 - (cursorSize / 2); RectComponent canvasComponent = canvas.GetComponent <RectComponent>(); guiCursor = canvasComponent.AddChild <RectImage>(cursorObjName); RectImage guiCursorComponent = guiCursor.GetComponent <RectImage>(); guiCursorComponent.size = new Vector2(cursorSize, cursorSize); guiCursorComponent.position = new Vector2(xPos, yPos); guiCursor.gameObject.SetActive(false); }