private void BuildCursor() { cursorGO = new GameObject(); cursorGO.name = "CURSOR"; cursorGO.transform.SetParent(mc.GetCursorParent().transform, true); Canvas cursor_canvas = cursorGO.AddComponent <Canvas>(); cursor_canvas.renderMode = RenderMode.WorldSpace; cursor_canvas.sortingLayerName = "TileUI"; cursor_canvas.referencePixelsPerUnit = 411.1f; RectTransform rt = cursorGO.GetComponent <RectTransform>(); rt.sizeDelta = new Vector2(10, 10); CanvasScaler cs = cursorGO.AddComponent <CanvasScaler>(); cs.dynamicPixelsPerUnit = 100.6f; cs.referencePixelsPerUnit = 411.1f; cursorSR = cursorGO.AddComponent <SpriteRenderer>(); cursorSR.sortingLayerName = "TileUI"; cursorSR.sprite = imgCursorSelect; upperLeft = new CursorTextBox(cursorGO, TextAnchor.MiddleRight, style, upperLeftPostion, size1); upperRight = new CursorTextBox(cursorGO, TextAnchor.MiddleLeft, style, upperRightPostion, size1); lowerLeft = new CursorTextBox(cursorGO, TextAnchor.MiddleRight, style, lowerLeftPostion, size2); lowerRight = new CursorTextBox(cursorGO, TextAnchor.MiddleLeft, style, lowerRightPostion, size2); Debug.Log("MouseCursorBuildInfo::Cursor Built"); }
private void BuildCursor() { cursorGO = new GameObject(); cursorGO.name = "CURSOR"; cursorGO.transform.SetParent(mc.GetCursorParent().transform, true); mc.GetCursorParent().name = "Cursor Canvas"; Canvas cursor_canvas = mc.GetCursorParent().AddComponent <Canvas>(); cursor_canvas.renderMode = RenderMode.ScreenSpaceOverlay; cursor_canvas.worldCamera = Camera.main; cursor_canvas.sortingLayerName = "TileUI"; cursor_canvas.referencePixelsPerUnit = 411.1f; RectTransform rt = mc.GetCursorParent().GetComponent <RectTransform>(); rt.sizeDelta = new Vector2(200, 200); CanvasScaler cs = mc.GetCursorParent().AddComponent <CanvasScaler>(); cs.dynamicPixelsPerUnit = 100.6f; cs.referencePixelsPerUnit = 411.1f; RectTransform rt1 = cursorGO.AddComponent <RectTransform>(); rt1.sizeDelta = new Vector2(64, 64); cursorSR = cursorGO.AddComponent <SpriteRenderer>(); cursorSR.sortingLayerName = "TileUI"; Cursor.SetCursor(cursorTexture, new Vector2(0, 0), CursorMode.Auto); upperLeft = new CursorTextBox(cursorGO, TextAnchor.MiddleRight, style, upperLeftPostion, cursorTextBoxSize); upperRight = new CursorTextBox(cursorGO, TextAnchor.MiddleLeft, style, upperRightPostion, cursorTextBoxSize); lowerLeft = new CursorTextBox(cursorGO, TextAnchor.MiddleRight, style, lowerLeftPostion, cursorTextBoxSize); lowerRight = new CursorTextBox(cursorGO, TextAnchor.MiddleLeft, style, lowerRightPostion, cursorTextBoxSize); }