コード例 #1
0
ファイル: UtilsClass.cs プロジェクト: BobThyAsian/Ants
        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;
            }));
        }
コード例 #2
0
ファイル: UI_TextComplex.cs プロジェクト: BobThyAsian/Ants
        // 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);
            }
        }
コード例 #3
0
ファイル: UI_TextComplex.cs プロジェクト: BobThyAsian/Ants
 private static Transform GetCanvasTransform()
 {
     return(UtilsClass.GetCanvasTransform());
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 private RectTransform SetupOutline(Outline outline, Vector2 size)
 {
     return(UtilsClass.DrawSprite(outline.color, gameObject.transform, Vector2.zero, size + new Vector2(outline.size, outline.size), "Outline"));
 }
コード例 #6
0
ファイル: World_Bar.cs プロジェクト: BobThyAsian/Ants
 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;
 }
コード例 #7
0
ファイル: World_Bar.cs プロジェクト: BobThyAsian/Ants
 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);
 }