コード例 #1
0
        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));
        }
コード例 #2
0
ファイル: RectMessageBox.cs プロジェクト: dmitryuck/shitrain
        protected static GameObject Init()
        {
            GameObject canvas = RectCanvas.GetCanvasObject();

            GameObject messageBoxObject = new GameObject("Message Box");

            messageBoxObject.transform.SetParent(canvas.transform);
            messageBoxObject.AddComponent <RectMessageBox>();

            return(messageBoxObject);
        }
コード例 #3
0
        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);
        }