当前位置: 首页>>代码示例>>C#>>正文


C# TextAnchor类代码示例

本文整理汇总了C#中TextAnchor的典型用法代码示例。如果您正苦于以下问题:C# TextAnchor类的具体用法?C# TextAnchor怎么用?C# TextAnchor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TextAnchor类属于命名空间,在下文中一共展示了TextAnchor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getScalingPivot

 private static Vector2 getScalingPivot(Rect rect, TextAnchor anchor)
 {
     switch (anchor)
     {
         case TextAnchor.LowerCenter:
             return new Vector2(rect.x + rect.width/2f, rect.y + rect.height);
         case TextAnchor.LowerLeft:
             return new Vector2(rect.x, rect.y + rect.height);
         case TextAnchor.LowerRight:
             return new Vector2(rect.x + rect.width, rect.y + rect.height);
         case TextAnchor.MiddleCenter:
             return new Vector2(rect.x + rect.width/2f, rect.y + rect.height/2f);
         case TextAnchor.MiddleLeft:
             return new Vector2(rect.x, rect.y + rect.height/2f);
         case TextAnchor.MiddleRight:
             return new Vector2(rect.x + rect.width, rect.y + rect.height/2f);
         case TextAnchor.UpperCenter:
             return new Vector2(rect.x + rect.width/2f, rect.y );
         case TextAnchor.UpperLeft:
             return new Vector2(rect.x, rect.y );
         case TextAnchor.UpperRight:
             return new Vector2(rect.x + rect.width, rect.y );
     }
     return Vector2.zero;
 }
开发者ID:Bizounours,项目名称:metaioSDK,代码行数:25,代码来源:GUIUtilities.cs

示例2: GetTextAnchorPivot

        public static Vector2 GetTextAnchorPivot(TextAnchor anchor)
        {
            switch (anchor)
            {
                case TextAnchor.UpperLeft:
                    return new Vector2(0f, 1f);

                case TextAnchor.UpperCenter:
                    return new Vector2(0.5f, 1f);

                case TextAnchor.UpperRight:
                    return new Vector2(1f, 1f);

                case TextAnchor.MiddleLeft:
                    return new Vector2(0f, 0.5f);

                case TextAnchor.MiddleCenter:
                    return new Vector2(0.5f, 0.5f);

                case TextAnchor.MiddleRight:
                    return new Vector2(1f, 0.5f);

                case TextAnchor.LowerLeft:
                    return new Vector2(0f, 0f);

                case TextAnchor.LowerCenter:
                    return new Vector2(0.5f, 0f);

                case TextAnchor.LowerRight:
                    return new Vector2(1f, 0f);
            }
            return Vector2.zero;
        }
开发者ID:randomize,项目名称:VimConfig,代码行数:33,代码来源:Text.cs

示例3: Declare

		public override void Declare ()
		{
			label = "Button";
			hotspotLabel = "";
			hotspotLabelID = -1;
			isVisible = true;
			isClickable = true;
			textEffects = TextEffects.None;
			buttonClickType = AC_ButtonClickType.RunActionList;
			simulateInput = SimulateInputType.Button;
			simulateValue = 1f;
			numSlots = 1;
			anchor = TextAnchor.MiddleCenter;
			SetSize (new Vector2 (10f, 5f));
			doFade = false;
			switchMenuTitle = "";
			inventoryBoxTitle = "";
			shiftInventory = AC_ShiftInventory.ShiftLeft;
			loopJournal = false;
			actionList = null;
			inputAxis = "";
			clickTexture = null;
			clickAlpha = 0f;
			shiftAmount = 1;
			onlyShowWhenEffective = false;
			allowContinuousClick = false;

			base.Declare ();
		}
开发者ID:amutnick,项目名称:CrackTheCode_Repo,代码行数:29,代码来源:MenuButton.cs

示例4: makeButton

            //every button needs to have own handler
            //bug Currently:
            //fontMat,font need to be set solid somewhere in a manager of sorts

            #region Creator

            //Creats a button and calls the need functions
            public static GameObject makeButton(Buttons bu, Transform parent, Vector3 pos = new Vector3(), int fontSize = 20, string text = "", int ToMenu = -1, string url = "", TextAnchor txmach = TextAnchor.UpperLeft)
            {
                GameObject b = null;
                switch (bu)
                {
                    case Buttons.Exit:
                       b = ExitButton.exitButton(fontMat, font, fontSize,txmach);
                        break;
                    case Buttons.ChangeMenu:
                        b = ChangeMenuButton.changeMenuButton(fontMat, font, fontSize, text, ToMenu, txmach);
                        break;
                    case Buttons.Link:
                        b = OpenLinkButton.openLinkButton(fontMat, font, fontSize, text, url, txmach);
                        break;
                    case Buttons.LevelLink:
                        b = menu.factory.button.LoadLevelButton.loadLevelButton(fontMat, font, fontSize, text, url, txmach);
                        break;
                    case Buttons.ResetHighScore:
                        b = ResetHighScoreButton.resetHighScoreButton(fontMat, font, fontSize, txmach);
                        break;
                    default:
                        b=new GameObject();
                        b.name="Buttons.##Error##";
                        Object.DestroyImmediate(b);
                        break;

                }
                b.transform.parent = parent;
                b.transform.position = pos;

                return b;
            }
开发者ID:nolimet,项目名称:GameJam2014,代码行数:39,代码来源:ButtonFactory.cs

示例5: CreateAdBanner

    //--------------------------------------
    //  PUBLIC METHODS
    //--------------------------------------
    public iAdBanner CreateAdBanner(TextAnchor anchor)
    {
        iAdBanner bannner = new iAdBanner(anchor, nextId);
        _banners.Add(bannner.id, bannner);

        return bannner;
    }
开发者ID:russellmorgan,项目名称:Super-Flappy-Fishy,代码行数:10,代码来源:iAdBannerController.cs

示例6: Reset

 public override void Reset()
 {
     gameObject = null;
     textAnchor = TextAnchor.LowerLeft;
     OrTextAnchorString = "";
     commit = true;
 }
开发者ID:davidmfry,项目名称:Sales-Ipad-app,代码行数:7,代码来源:Tk2dTextMeshSetAnchor.cs

示例7: CreateUIBoard

    public Menu_Board CreateUIBoard(string _text, TextAnchor _aligment, float _xRatio, float _yRatio, float _widthRatio, float _heightRatio)
    {
        Menu_Board board = null;

        for (int i = 0; i < mBoardList.Count; i++)
        {
            if (!mBoardList[i].IsUsing)
            {
                board = mBoardList[i];
                break;
            }
        }

        if (board == null)
        {
            board = GameObject.Instantiate(m_BoardPrefab).GetComponent<Menu_Board>();
            mBoardList.Add(board);
        }

        board.transform.SetParent(m_Canvas.transform);
        board.transform.SetAsFirstSibling();
        board.SetRectInfo(_xRatio, _yRatio, _widthRatio, _heightRatio);
        board.SetBoardInfo(_text, _aligment);
        board.SetMoveStatus(MenuItemBase.emMoveStatus.In);

        return board;
    }
开发者ID:DeanLu,项目名称:SnowBall,代码行数:27,代码来源:UIManager_ItemCollect.cs

示例8: GetPosition

    Vector2 GetPosition(RectTransform rt, TextAnchor anchor)
    {
        Vector2 retValue = Vector2.zero;

        switch (anchor) {
        case TextAnchor.LowerCenter:
        case TextAnchor.MiddleCenter:
        case TextAnchor.UpperCenter:
            retValue.x += rt.rect.width * 0.5f;
            break;
        case TextAnchor.LowerRight:
        case TextAnchor.MiddleRight:
        case TextAnchor.UpperRight:
            retValue.x += rt.rect.width;
            break;
        }

        switch (anchor) {
        case TextAnchor.MiddleLeft:
        case TextAnchor.MiddleCenter:
        case TextAnchor.MiddleRight:
            retValue.y += rt.rect.height * 0.5f;
            break;
        case TextAnchor.UpperLeft:
        case TextAnchor.UpperCenter:
        case TextAnchor.UpperRight:
            retValue.y += rt.rect.height;
            break;
        }

        return retValue;
    }
开发者ID:arthurwoo,项目名称:TaticsHero,代码行数:32,代码来源:LayoutAnchor.cs

示例9: ShowText

    public static GameObject ShowText(string name, string text, float time, TextAlignment alignment, TextAnchor anchor, float x, float y)
    {
        LoadFonts();

        // Destroy old object if existent
        GameObject textObject = GameObject.Find(PREFIX + name);
        MonoBehaviour.Destroy(textObject);

        textObject = new GameObject(PREFIX + name);

        textObject.AddComponent<OutlineText>().thickness = 2;

        TutorialText textBehaviour = textObject.GetComponent<TutorialText>();

        if (textBehaviour == null)
            textBehaviour = textObject.AddComponent<TutorialText>();

        GUIScale textScaler = textObject.GetComponent<GUIScale>();
        GUIText guitext = textObject.guiText;
        guitext.enabled = true;

        textObject.transform.position = new Vector3(x, y, 0);

        guitext.text = text;
        guitext.anchor = anchor;
        guitext.alignment = alignment;
        //guitext.font = bigFont;
        //guitext.material = bigMat;
        //guitext.fontSize = 48;

        if (time > 0)
            textBehaviour.DestroyIn(time);

        return textObject;
    }
开发者ID:mokacao,项目名称:StellarSwingClassic,代码行数:35,代码来源:Tutorial.cs

示例10: exitButton

 public static GameObject exitButton(Material m, Font ft, int Size, TextAnchor txmach = TextAnchor.UpperLeft)
 {
     GameObject b = MakeBase(m,ft,"Exit",Size,txmach);
     b.AddComponent<ExitGame>();
     b.name = "Exit";
     return b;
 }
开发者ID:nolimet,项目名称:GameJam2014,代码行数:7,代码来源:ExitButton.cs

示例11: resetHighScoreButton

                public static GameObject resetHighScoreButton(Material m, Font ft, int Size, TextAnchor txmach = TextAnchor.UpperLeft)
                {
                    GameObject b = MakeBase(m, ft, "Reset HighScore", Size, txmach);
                    b.AddComponent<ResetHighScore>();

                    return b;
                }
开发者ID:nolimet,项目名称:GameJam2014,代码行数:7,代码来源:ResetHighScoreButton.cs

示例12: CalculateGuiRect

 /// <summary>
 /// calculate the area in which we draw the GUI, considering the current anchor option
 /// </summary>
 /// <param name="anchor">In what area of the scene view we should draw</param>
 /// <param name="sceneCamera">The camera of the scene view in which we render the GUI</param>
 /// <param name="isPreviewOpen">Whether or not there's an open Camera Preview window on the scene view</param>
 /// <returns>the GUI area in the appropriate anchor position</returns>
 private static Rect CalculateGuiRect(TextAnchor anchor, Camera sceneCamera, bool isPreviewOpen)
 {
     switch(anchor)
     {
         case TextAnchor.UpperLeft:
             return new Rect(GUI_AREA_MARGIN, GUI_AREA_MARGIN, WIDTH, HEIGHT);
         case TextAnchor.UpperCenter:
             return new Rect((sceneCamera.pixelWidth / 2f) - (WIDTH / 2f), GUI_AREA_MARGIN, WIDTH, HEIGHT);
         case TextAnchor.UpperRight:
             return new Rect((sceneCamera.pixelWidth - WIDTH - GUI_AREA_MARGIN) - UNITY_GIZMO_WIDTH, GUI_AREA_MARGIN, WIDTH, HEIGHT);
         case TextAnchor.MiddleLeft:
             return new Rect(GUI_AREA_MARGIN, (sceneCamera.pixelHeight / 2f) - (HEIGHT / 2f), WIDTH, HEIGHT);
         case TextAnchor.MiddleCenter:
             return new Rect((sceneCamera.pixelWidth / 2f) - (WIDTH / 2f), (sceneCamera.pixelHeight / 2f) - (HEIGHT / 2f), WIDTH, HEIGHT);
         case TextAnchor.MiddleRight:
             return new Rect((sceneCamera.pixelWidth - WIDTH - GUI_AREA_MARGIN), (sceneCamera.pixelHeight / 2f) - (HEIGHT / 2f), WIDTH, HEIGHT);
         case TextAnchor.LowerLeft:
             return new Rect(GUI_AREA_MARGIN, (sceneCamera.pixelHeight - HEIGHT - GUI_AREA_MARGIN), WIDTH, HEIGHT);
         case TextAnchor.LowerCenter:
             return new Rect((sceneCamera.pixelWidth / 2f) - (WIDTH / 2f), (sceneCamera.pixelHeight - HEIGHT - GUI_AREA_MARGIN), WIDTH, HEIGHT);
         case TextAnchor.LowerRight:
             float offset = 0;
             if(isPreviewOpen)
             {
                 offset = (sceneCamera.pixelWidth * CAMERA_PREVIEW_NORMALIZED) + CAMERA_PREVIEW_OFFSET + (GUI_AREA_MARGIN * 2);
             }
             return new Rect((sceneCamera.pixelWidth - WIDTH - GUI_AREA_MARGIN - offset), (sceneCamera.pixelHeight - HEIGHT - GUI_AREA_MARGIN), WIDTH, HEIGHT);
         default:
             goto case TextAnchor.UpperLeft;
     }
 }
开发者ID:jmschrack,项目名称:LudumDare33,代码行数:38,代码来源:SceneGuiDrawer.cs

示例13: AnchoredLabel

 /// <summary>
 /// Displays a label with adjustable anchoring
 /// </summary>
 /// <param name='text'>
 /// Text.
 /// </param>
 /// <param name='alignment'>
 /// Alignment.
 /// </param>
 /// <param name='options'>
 /// Options.
 /// </param>
 public static void AnchoredLabel(string text, TextAnchor alignment, params GUILayoutOption[] options)
 {
     TextAnchor oldAnchor = GUI.skin.label.alignment;
     GUI.skin.label.alignment = alignment;
     GUILayout.Label(text,options);
     GUI.skin.label.alignment = oldAnchor;
 }
开发者ID:EJBQ,项目名称:Bae-Zeus-X,代码行数:19,代码来源:AmazonGUIHelpers.cs

示例14: ToSDKTextAnchor

        public TextAnchor ToSDKTextAnchor()
        {
            if (apiExtractAnchor == null)
            {
                return sdkTextAnchor;
            }
            else
            {
                TextAnchor result = new TextAnchor();

                result.Position = new TextAnchorPositionConverter(apiExtractAnchor.AnchorPoint).ToSDKTextAnchorPosition();
                
                if ( apiExtractAnchor.Index.HasValue )
                    result.Occurrence = apiExtractAnchor.Index.Value;
                    
                result.AnchorText = apiExtractAnchor.Text;
                
                if (apiExtractAnchor.CharacterIndex.HasValue)
                    result.Character = apiExtractAnchor.CharacterIndex.Value;
                    
                if (apiExtractAnchor.LeftOffset.HasValue)
                    result.XOffset = apiExtractAnchor.LeftOffset.Value;
                    
                if (apiExtractAnchor.TopOffset.HasValue)
                    result.YOffset = apiExtractAnchor.TopOffset.Value;
                    
                if (apiExtractAnchor.Width.HasValue)
                    result.Width = apiExtractAnchor.Width.Value;
                    
                if (apiExtractAnchor.Height.HasValue)
                    result.Height = apiExtractAnchor.Height.Value;

                return result;
            }
        }
开发者ID:vtcharlie,项目名称:esl.sdk.net,代码行数:35,代码来源:TextAnchorConverter.cs

示例15: CalculateGuiRect

 /// <summary>
 /// calculate the area in which we draw the GUI, considering the current anchor option
 /// </summary>
 /// <param name="anchor">In what area of the scene view we should draw</param>
 /// <param name="sceneCamera">The camera of the scene view in which we render the GUI</param>
 /// <returns>the GUI area in the appropriate anchor position</returns>
 private static Rect CalculateGuiRect(TextAnchor anchor, Camera sceneCamera)
 {
     switch (anchor)
     {
         case TextAnchor.UpperLeft:
             return new Rect(GUI_AREA_MARGIN, GUI_AREA_MARGIN, WIDTH, HEIGHT);
         case TextAnchor.UpperCenter:
             return new Rect((sceneCamera.pixelWidth / 2f) - (WIDTH / 2f), GUI_AREA_MARGIN, WIDTH, HEIGHT);
         case TextAnchor.UpperRight:
             return new Rect((sceneCamera.pixelWidth - WIDTH - GUI_AREA_MARGIN) - UNITY_GIZMO_WIDTH, GUI_AREA_MARGIN, WIDTH, HEIGHT);
         case TextAnchor.MiddleLeft:
             return new Rect(GUI_AREA_MARGIN, (sceneCamera.pixelHeight / 2f) - (HEIGHT / 2f), WIDTH, HEIGHT);
         case TextAnchor.MiddleCenter:
             return new Rect((sceneCamera.pixelWidth / 2f) - (WIDTH / 2f), (sceneCamera.pixelHeight / 2f) - (HEIGHT / 2f), WIDTH, HEIGHT);
         case TextAnchor.MiddleRight:
             return new Rect((sceneCamera.pixelWidth - WIDTH - GUI_AREA_MARGIN), (sceneCamera.pixelHeight / 2f) - (HEIGHT / 2f), WIDTH, HEIGHT);
         case TextAnchor.LowerLeft:
             return new Rect(GUI_AREA_MARGIN, (sceneCamera.pixelHeight - HEIGHT - GUI_AREA_MARGIN), WIDTH, HEIGHT);
         case TextAnchor.LowerCenter:
             return new Rect((sceneCamera.pixelWidth / 2f) - (WIDTH / 2f), (sceneCamera.pixelHeight - HEIGHT - GUI_AREA_MARGIN), WIDTH, HEIGHT);
         case TextAnchor.LowerRight:
             return new Rect((sceneCamera.pixelWidth - WIDTH - GUI_AREA_MARGIN), (sceneCamera.pixelHeight - HEIGHT - GUI_AREA_MARGIN), WIDTH, HEIGHT);
         default:
             goto case TextAnchor.UpperLeft;
     }
 }
开发者ID:JuanJosePol,项目名称:ggjmallorca2016,代码行数:32,代码来源:SceneGuiDrawer.cs


注:本文中的TextAnchor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。