public static FunctionUpdater CreateMouseDraggingAction(int mouseButton, Action <Vector3> onMouseDragging) { bool dragging = false; return(FunctionUpdater.Create(() => { if (Input.GetMouseButtonDown(mouseButton)) { dragging = true; } if (Input.GetMouseButtonUp(mouseButton)) { dragging = false; } if (dragging) { onMouseDragging(UtilsClass.GetMouseWorldPosition()); } return false; })); }
// iconChar prepends the iconArr index; // Example using iconChar '#': // test #0 asdf // Displays "test [iconArr[0]] asdf" public UI_TextComplex(Transform parent, Vector2 anchoredPosition, int fontSize, char iconChar, string text, Icon[] iconArr, Font font) { SetupParent(parent, anchoredPosition); string tmp = text; float textPosition = 0f; while (tmp.IndexOf(iconChar) != -1) { string untilTmp = tmp.Substring(0, tmp.IndexOf(iconChar)); string iconNumber = tmp.Substring(tmp.IndexOf(iconChar) + 1); int indexOfSpaceAfterIconNumber = iconNumber.IndexOf(" "); if (indexOfSpaceAfterIconNumber != -1) { // Still has more space after iconNumber iconNumber = iconNumber.Substring(0, indexOfSpaceAfterIconNumber); } else { // No more space after iconNumber } tmp = tmp.Substring(tmp.IndexOf(iconChar + iconNumber) + (iconChar + iconNumber).Length); if (untilTmp.Trim() != "") { Text uiText = UtilsClass.DrawTextUI(untilTmp, transform, new Vector2(textPosition, 0), fontSize, font); textPosition += uiText.preferredWidth; } // Draw Icon int iconIndex = UtilsClass.Parse_Int(iconNumber, 0); Icon icon = iconArr[iconIndex]; UtilsClass.DrawSprite(icon.sprite, transform, new Vector2(textPosition + icon.size.x / 2f, 0), icon.size); textPosition += icon.size.x; } if (tmp.Trim() != "") { UtilsClass.DrawTextUI(tmp, transform, new Vector2(textPosition, 0), fontSize, font); } }
private static Transform GetCanvasTransform() { return(UtilsClass.GetCanvasTransform()); }
private void SetupBackground(Color backgroundColor) { background = UtilsClass.DrawSprite(backgroundColor, gameObject.transform, Vector2.zero, Vector2.zero, "Background"); background.anchorMin = new Vector2(0, 0); background.anchorMax = new Vector2(1, 1); }
private RectTransform SetupOutline(Outline outline, Vector2 size) { return(UtilsClass.DrawSprite(outline.color, gameObject.transform, Vector2.zero, size + new Vector2(outline.size, outline.size), "Outline")); }
private void SetupBackground(Color backgroundColor, Vector3 localScale, int sortingOrder) { background = UtilsClass.CreateWorldSprite(transform, "Background", Assets.i.s_White, new Vector3(0, 0), localScale, sortingOrder, backgroundColor).transform; }
private void SetupOutline(Outline outline, Vector3 localScale, int sortingOrder) { UtilsClass.CreateWorldSprite(transform, "Outline", Assets.i.s_White, new Vector3(0, 0), localScale + new Vector3(outline.size, outline.size), sortingOrder, outline.color); }