コード例 #1
0
		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 ();
		}
コード例 #2
0
ファイル: Text.cs プロジェクト: randomize/VimConfig
        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;
        }
コード例 #3
0
    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;
    }
コード例 #4
0
ファイル: GUIUtilities.cs プロジェクト: Bizounours/metaioSDK
 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;
 }
コード例 #5
0
ファイル: ButtonFactory.cs プロジェクト: nolimet/GameJam2014
            //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;
            }
コード例 #6
0
        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;
            }
        }
コード例 #7
0
ファイル: MenuButton.cs プロジェクト: IJkeB/Ekster_Final
        public void CopyButton(MenuButton _element)
        {
            uiButton = _element.uiButton;
            uiText = _element.uiText;
            label = _element.label;
            hotspotLabel = _element.hotspotLabel;
            hotspotLabelID = _element.hotspotLabelID;
            anchor = _element.anchor;
            textEffects = _element.textEffects;
            buttonClickType = _element.buttonClickType;
            simulateInput = _element.simulateInput;
            simulateValue = _element.simulateValue;
            doFade = _element.doFade;
            switchMenuTitle = _element.switchMenuTitle;
            inventoryBoxTitle = _element.inventoryBoxTitle;
            shiftInventory = _element.shiftInventory;
            loopJournal = _element.loopJournal;
            actionList = _element.actionList;
            inputAxis = _element.inputAxis;
            clickTexture = _element.clickTexture;
            clickAlpha = _element.clickAlpha;
            shiftAmount = _element.shiftAmount;
            onlyShowWhenEffective = _element.onlyShowWhenEffective;
            allowContinuousClick = _element.allowContinuousClick;
            parameterID = _element.parameterID;
            parameterValue = _element.parameterValue;

            base.Copy (_element);
        }
コード例 #8
0
 /// <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;
     }
 }
コード例 #9
0
ファイル: LayoutAnchor.cs プロジェクト: arthurwoo/TaticsHero
    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;
    }
コード例 #10
0
ファイル: ExitButton.cs プロジェクト: nolimet/GameJam2014
 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;
 }
コード例 #11
0
    //--------------------------------------
    //  PUBLIC METHODS
    //--------------------------------------
    public iAdBanner CreateAdBanner(TextAnchor anchor)
    {
        iAdBanner bannner = new iAdBanner(anchor, nextId);
        _banners.Add(bannner.id, bannner);

        return bannner;
    }
コード例 #12
0
    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;
    }
コード例 #13
0
ファイル: AmazonGUIHelpers.cs プロジェクト: EJBQ/Bae-Zeus-X
 /// <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;
 }
コード例 #14
0
 public override void Reset()
 {
     gameObject = null;
     textAnchor = TextAnchor.LowerLeft;
     OrTextAnchorString = "";
     commit = true;
 }
コード例 #15
0
                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;
                }
コード例 #16
0
 /// <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;
     }
 }
コード例 #17
0
    //--------------------------------------
    // INITIALIZE
    //--------------------------------------
    public AndroidADBanner(TextAnchor anchor, GADBannerSize size, int id)
    {
        _id = id;
        _size = size;
        _anchor = anchor;

        AN_GoogleAdProxy.CreateBannerAd (gravity, (int) _size, _id);
    }
コード例 #18
0
ファイル: MenuTemplate.cs プロジェクト: Zulban/viroid
    public static GUIStyle getLabelStyle(int fontDivisor, TextAnchor textAnchor, Color color)
    {
        GUIStyle newStyle = getLabelStyle (fontDivisor);
        newStyle.alignment = textAnchor;
        newStyle.normal.textColor = color;

        return newStyle;
    }
コード例 #19
0
        /// <summary>
        /// Fill label mesh.
        /// </summary>
        /// <param name="mesh">Mesh.</param>
        /// <param name="width">Label width.</param>
        /// <param name="height">Label height.</param>
        /// <param name="text">Label text.</param>
        /// <param name="color">Color.</param>
        /// <param name="align">Text align.</param>
        /// <param name="font">Font.</param>
        /// <param name="fontSize">Font size.</param>
        /// <param name="lineHgt">Line height multiplier.</param>
        /// <param name="effect">Effect.</param>
        /// <param name="effectValue">Effect value.</param>
        /// <param name="effectColor">Effect color.</param>
        public static void FillText(
            Mesh mesh, int width, int height, string text, Color color, TextAnchor align, Font font, int fontSize,
            float lineHgt, GuiFontEffect effect = GuiFontEffect.None, Vector2? effectValue = null, Color? effectColor = null)
        {
            if (mesh == null) {
                return;
            }
            mesh.Clear ();
            if (font == null || string.IsNullOrEmpty (text)) {
                return;
            }

            _settings.fontSize = (int) (fontSize * GuiSystem.Instance.VirtualToRealScaleFactor);
            _settings.resizeTextMaxSize = _settings.fontSize;

            var scale = fontSize / (float) _settings.fontSize;

            _settings.font = font;
            _settings.textAnchor = align;
            _settings.generationExtents = new Vector2 (width, height) / scale;
            _settings.lineSpacing = lineHgt;
            _settings.color = color;
            _generator.Invalidate ();
            if (!_generator.Populate (text, _settings)) {
                return;
            }

            _generator.GetVertices (_verts);

            GuiMeshTools.PrepareBuffer (effect, effectValue, effectColor);

            for (int i = 0, iMax = _verts.Count - 4, charID = 0; i < iMax; charID++) {
                if (text[charID] == ' ') {
                    i += 4;
                    continue;
                }
                _uiV = _verts[i++];
                _c = _uiV.color;
                _v0 = _uiV.position * scale;
                _uv0 = _uiV.uv0;

                _uiV = _verts[i++];
                _v1 = _uiV.position * scale;
                _uv1 = _uiV.uv0;

                _uiV = _verts[i++];
                _v2 = _uiV.position * scale;
                _uv2 = _uiV.uv0;

                _uiV = _verts[i++];
                _v3 = _uiV.position * scale;
                _uv3 = _uiV.uv0;
                GuiMeshTools.FillBuffer (ref _v0, ref _v1, ref _v2, ref _v3, ref _uv0, ref _uv1, ref _uv2, ref _uv3, ref _c);
            }

            GuiMeshTools.GetBuffers (mesh, false);
            mesh.bounds = new Bounds (Vector3.zero, new Vector3 (width, height, 0f));
        }
コード例 #20
0
	//--------------------------------------
	// INITIALIZE
	//--------------------------------------

	public AndroidADBanner(TextAnchor anchor, GADBannerSize size, int id) {
		_id = id;
		_size = size;
		_anchor = anchor;
	

		AndroidNative.CreateBannerAd (gravity, (int) _size, _id);

	}
コード例 #21
0
ファイル: GUITool.cs プロジェクト: pb0/ID0_Test
    public static void DrawText(Rect rect, string text, Color color, int fontSize, TextAnchor anchor)
    {
        GUIStyle style = new GUIStyle();
        style.fontSize = fontSize;
        style.normal.textColor = color;
        style.alignment = anchor;

        GUI.Label(rect, text, style);
    }
コード例 #22
0
		public void CopyInteraction (MenuInteraction _element)
		{
			displayType = _element.displayType;
			anchor = _element.anchor;
			textEffects = _element.textEffects;
			iconID = _element.iconID;
			
			base.Copy (_element);
		}
コード例 #23
0
	public iAdBanner(TextAnchor anchor,  int id) {
		_id = id;
		_anchor = anchor;
		
		
		#if (UNITY_IPHONE && !UNITY_EDITOR) || SA_DEBUG_MODE
			_IADCreateBannerAd(gravity, _id);
		#endif
	}
コード例 #24
0
    public iAdBanner(TextAnchor anchor,  int id)
    {
        _id = id;
        _anchor = anchor;

        if(Application.platform == RuntimePlatform.IPhonePlayer) {
            _IADCreateBannerAd(gravity, _id);
        }
    }
コード例 #25
0
                public static GameObject changeMenuButton(Material m, Font ft, int Size, string text,int toMenu, TextAnchor txmach = TextAnchor.UpperLeft)
                {
                    GameObject b = MakeBase(m,ft,text,Size,txmach);
                    ChangeMenu cm = b.AddComponent<ChangeMenu>();
                    cm.OpenMenuID = toMenu;
                    b.name = text;

                    return b;
                }
コード例 #26
0
ファイル: GUIHelper.cs プロジェクト: Mnemorie/unifit
    static public void DrawTextWithOutline(Rect r, string t, Color color, TextAnchor alignment)
    {
        GUI.skin.label.alignment = TextAnchor.MiddleCenter;

        GUIHelper.DrawOutline(r, t, 2);
        GUI.color = Color.white;

        GUI.Label(r, t);
    }
コード例 #27
0
    public static GUIStyle CustomElement(GUIStyle style, Color color, Color textColor, TextAnchor textAlignment, FontStyle fontStyle, int fontSize)
    {
        GUIStyle newStyle = new GUIStyle(style);
        newStyle.fontStyle = fontStyle;
        newStyle.fontSize = fontSize;
        newStyle.alignment = textAlignment;
        newStyle.normal.textColor = textColor;

        return newStyle;
    }
コード例 #28
0
ファイル: IOSADBanner.cs プロジェクト: sonth3vn/DFTChess
    //--------------------------------------
    // INITIALIZE
    //--------------------------------------
    public IOSADBanner(TextAnchor anchor, GADBannerSize size, int id)
    {
        _id = id;
        _size = size;
        _anchor = anchor;

        #if (UNITY_IPHONE && !UNITY_EDITOR) || SA_DEBUG_MODE
        _GADCreateBannerAd(gravity, (int) _size, _id);
        #endif
    }
コード例 #29
0
ファイル: WP8ADBanner.cs プロジェクト: sonxoans2/TapJump
	//--------------------------------------
	// INITIALIZE
	//--------------------------------------
	
	public WP8ADBanner(TextAnchor anchor, GADBannerSize size, int id) {
		_id = id;
		_size = size;
		_anchor = anchor;

		#if (UNITY_WP8 && !UNITY_EDITOR) || SA_DEBUG_MODE
		AdManager.instance.CreateBannerAd((int)size, id, (int)anchor);
		#endif
		
	}
コード例 #30
0
ファイル: GuiManager.cs プロジェクト: Ben-P-Leda/Dogfighter
        public Rect ScaleToDisplay(float width, float height, TextAnchor alignment, float horizontalMargin, float verticalMargin)
        {
            if (!_initialized) { Initialize(); }

            horizontalMargin *= Scaling;
            verticalMargin *= Scaling;
            width *= Scaling;
            height *= Scaling;

            float left = _viewportScreenArea.x + ((_viewportScreenArea.width - width) / 2.0f);
            float top = Screen.height - (_viewportScreenArea.y + ((_viewportScreenArea.height + height) / 2.0f));

            if ((alignment == TextAnchor.LowerLeft) || (alignment == TextAnchor.MiddleLeft) || (alignment == TextAnchor.UpperLeft))
            {
                left = _viewportScreenArea.x + horizontalMargin;
            }
            else if ((alignment == TextAnchor.LowerRight) || (alignment == TextAnchor.MiddleRight) || (alignment == TextAnchor.UpperRight))
            {
                left = (_viewportScreenArea.x + _viewportScreenArea.width) - (width + horizontalMargin);
            }

            if ((alignment == TextAnchor.UpperLeft) || (alignment == TextAnchor.UpperCenter) || (alignment == TextAnchor.UpperRight))
            {
                top = Screen.height - (_viewportScreenArea.y + _viewportScreenArea.height - verticalMargin);
            }
            else if ((alignment == TextAnchor.LowerLeft) || (alignment == TextAnchor.LowerCenter) || (alignment == TextAnchor.LowerRight))
            {
                top = Screen.height - (_viewportScreenArea.y + verticalMargin + height);
            }

            return new Rect(left, top, width, height);

            //float left = _viewportScreenArea.x + ((_viewportScreenArea.width - width) / 2.0f);
            //float top = _viewportScreenArea.y + ((_viewportScreenArea.height - height) / 2.0f);

            //if ((alignment == TextAnchor.LowerLeft) || (alignment == TextAnchor.MiddleLeft) || (alignment == TextAnchor.UpperLeft))
            //{
            //    left = _viewportScreenArea.x + horizontalMargin;
            //}
            //else if ((alignment == TextAnchor.LowerRight) || (alignment == TextAnchor.MiddleRight) || (alignment == TextAnchor.UpperRight))
            //{
            //    left = (_viewportScreenArea.x + _viewportScreenArea.width) - (width + horizontalMargin);
            //}

            //if ((alignment == TextAnchor.UpperLeft) || (alignment == TextAnchor.UpperCenter) || (alignment == TextAnchor.UpperRight))
            //{
            //    top = _viewportScreenArea.y + verticalMargin;
            //}
            //else if ((alignment == TextAnchor.LowerLeft) || (alignment == TextAnchor.LowerCenter) || (alignment == TextAnchor.LowerRight))
            //{
            //    top = (_viewportScreenArea.y + _viewportScreenArea.height) - (height + verticalMargin);
            //}

            //return new Rect(left, top, width, height);
        }
コード例 #31
0
 static public void CreateLabel(ref CuiElementContainer container, string panel, string color, string text, int size, string aMin, string aMax, TextAnchor align = TextAnchor.MiddleCenter)
 {
     container.Add(new CuiLabel
     {
         Text          = { Color = color, FontSize = size, Align = align, Text = text },
         RectTransform = { AnchorMin = aMin, AnchorMax = aMax }
     },
                   panel);
 }
コード例 #32
0
        public static void Box(this HUMEditor.Data.Horizontal horizontal, Color backgroundColor, Color borderColor, RectOffset padding, TextAnchor contentAlignment, int border = 1, Action contents = null, params GUILayoutOption[] options)
        {
            var style       = new GUIStyle();
            var borderStyle = new GUIStyle();

            style.normal.background       = HUMTexture.Create(1, 1).Color(backgroundColor);
            borderStyle.normal.background = HUMTexture.Create(1, 1).Color(borderColor);
            borderStyle.padding           = new RectOffset(border, border, border, border);
            style.padding   = padding;
            style.alignment = contentAlignment;

            HUMEditor.Horizontal(borderStyle, () =>
            {
                HUMEditor.Horizontal(style, () =>
                {
                    contents?.Invoke();
                });
            }, options);
        }
コード例 #33
0
        public override void ShowGUI(Menu menu)
        {
            MenuSource source = menu.menuSource;

            EditorGUILayout.BeginVertical("Button");

            fixedOption = EditorGUILayout.ToggleLeft("Fixed Profile ID only?", fixedOption);
            if (fixedOption)
            {
                numSlots     = 1;
                slotSpacing  = 0f;
                optionToShow = EditorGUILayout.IntField("ID to display:", optionToShow);
            }
            else
            {
                showActive = EditorGUILayout.Toggle("Include active?", showActive);
                maxSlots   = EditorGUILayout.IntField("Max no. of slots:", maxSlots);

                if (source == MenuSource.AdventureCreator)
                {
                    numSlots    = EditorGUILayout.IntSlider("Test slots:", numSlots, 1, maxSlots);
                    slotSpacing = EditorGUILayout.Slider("Slot spacing:", slotSpacing, 0f, 20f);
                    orientation = (ElementOrientation)EditorGUILayout.EnumPopup("Slot orientation:", orientation);
                    if (orientation == ElementOrientation.Grid)
                    {
                        gridWidth = EditorGUILayout.IntSlider("Grid size:", gridWidth, 1, 10);
                    }
                }
            }

            if (source == MenuSource.AdventureCreator)
            {
                anchor      = (TextAnchor)EditorGUILayout.EnumPopup("Text alignment:", anchor);
                textEffects = (TextEffects)EditorGUILayout.EnumPopup("Text effect:", textEffects);
                if (textEffects != TextEffects.None)
                {
                    outlineSize = EditorGUILayout.Slider("Effect size:", outlineSize, 1f, 5f);
                }
            }

            autoHandle = EditorGUILayout.ToggleLeft("Switch profile when click on?", autoHandle);

            if (autoHandle)
            {
                ActionListGUI("ActionList after selecting:", menu.title, "After_Selecting");
            }
            else
            {
                ActionListGUI("ActionList when click:", menu.title, "When_Click");
            }

            if (source != MenuSource.AdventureCreator)
            {
                EditorGUILayout.EndVertical();
                EditorGUILayout.BeginVertical("Button");
                uiHideStyle = (UIHideStyle)EditorGUILayout.EnumPopup("When invisible:", uiHideStyle);
                EditorGUILayout.LabelField("Linked button objects", EditorStyles.boldLabel);

                uiSlots = ResizeUISlots(uiSlots, maxSlots);
                for (int i = 0; i < uiSlots.Length; i++)
                {
                    uiSlots[i].LinkedUiGUI(i, source);
                }
            }

            EditorGUILayout.EndVertical();

            base.ShowGUI(menu);
        }
コード例 #34
0
        //Cria um Text no algum lugar do mundo(usada pela de cima)
        public static TextMesh CreateWorldText(Transform parent, string text, Vector3 localposition, int fontSize, Color color, TextAnchor textAnchor, TextAlignment textAlignment, int sortingOrder)
        {
            //Cria um novo objetocom um componet TextMesh, com o nome de World Text
            GameObject gameObject = new GameObject("World Text", typeof(TextMesh));
            // Arruma o text mesh como filho do "parent" fornecido
            Transform transform = gameObject.transform;

            transform.SetParent(parent, false);
            //Arruma a posição dele para a desenjada em "localPosition"
            transform.localPosition = localposition;
            //Arruma os parametros do componente TextMesh para os indicados na função
            TextMesh textMesh = gameObject.GetComponent <TextMesh>();

            textMesh.anchor    = textAnchor;
            textMesh.alignment = textAlignment;
            textMesh.text      = text;
            textMesh.fontSize  = fontSize;
            textMesh.color     = color;
            //Arruma a ordem do mesh renderer
            textMesh.GetComponent <MeshRenderer>().sortingOrder = sortingOrder;
            return(textMesh);
        }
コード例 #35
0
            // Create Text in the World
            public static TextMesh CreateWorldText(Transform parent, string text, Vector3 localPosition, int fontSize, Color?color, TextAnchor textAnchor, TextAlignment textAlignment, int sortingOrder)
            {
                if (color == null)
                {
                    color = Color.white;
                }

                GameObject gameObject = new GameObject("LC_WorldText", typeof(TextMesh));
                Transform  transform  = gameObject.transform;

                #region Custom conf - jLautaroCabral

                transform.localScale = Vector3.one * 0.1f;

                #endregion Custom conf - jLautaroCabral

                transform.SetParent(parent, false);
                transform.localPosition = localPosition;

                TextMesh textMesh = gameObject.GetComponent <TextMesh>();
                textMesh.anchor    = textAnchor;
                textMesh.alignment = textAlignment;
                textMesh.text      = text;
                textMesh.fontSize  = fontSize;
                textMesh.color     = (Color)color;
                textMesh.GetComponent <MeshRenderer>().sortingOrder = sortingOrder;

                LC_Debug.RuntimeDebugObjectsManager.debugObjects.Add(gameObject);

                return(textMesh);
            }
コード例 #36
0
        void InitAlignment_UGUI(bool isRTL, TextAnchor alignment, out TextAnchor alignLTR, out TextAnchor alignRTL)
        {
            alignLTR = alignRTL = alignment;

            if (isRTL)
            {
                switch (alignment)
                {
                case TextAnchor.UpperRight:         alignLTR = TextAnchor.UpperLeft; break;

                case TextAnchor.MiddleRight:        alignLTR = TextAnchor.MiddleLeft; break;

                case TextAnchor.LowerRight:             alignLTR = TextAnchor.LowerLeft; break;

                case TextAnchor.UpperLeft:              alignLTR = TextAnchor.UpperRight; break;

                case TextAnchor.MiddleLeft:             alignLTR = TextAnchor.MiddleRight; break;

                case TextAnchor.LowerLeft:              alignLTR = TextAnchor.LowerRight; break;
                }
            }
            else
            {
                switch (alignment)
                {
                case TextAnchor.UpperRight: alignRTL = TextAnchor.UpperLeft; break;

                case TextAnchor.MiddleRight: alignRTL = TextAnchor.MiddleLeft; break;

                case TextAnchor.LowerRight: alignRTL = TextAnchor.LowerLeft; break;

                case TextAnchor.UpperLeft:      alignRTL = TextAnchor.UpperRight; break;

                case TextAnchor.MiddleLeft: alignRTL = TextAnchor.MiddleRight; break;

                case TextAnchor.LowerLeft:  alignRTL = TextAnchor.LowerRight; break;
                }
            }
        }
コード例 #37
0
ファイル: FontBatch3D.cs プロジェクト: Suceru/sc2.2mobile
 public void QueueText(string text, Vector3 position, Vector3 right, Vector3 down, Color color, TextAnchor anchor = TextAnchor.Default)
 {
     QueueText(text, position, right, down, color, anchor, Vector2.Zero);
 }
コード例 #38
0
 public static TextMesh CreateWorldText(string text, Transform parent = null, Vector3 localPosition = default(Vector3), int fontSize = 40, Color?color = null, TextAnchor textAnchor = TextAnchor.UpperLeft, TextAlignment textAlignment = TextAlignment.Left, int sortingOrder = LC_Utils.sortingOrderDefault)
 {
     return(CreateWorldText(parent, text, localPosition, fontSize, color, textAnchor, textAlignment, sortingOrder));
 }
コード例 #39
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        if (GUILayout.Button("DONT EVER CLICK ME!"))
        {
            Text[] texts = GameObject.FindObjectsOfType <Text>();
            foreach (Text text in texts)
            {
                TextMeshProUGUI tmpro = text.gameObject.GetComponent <TextMeshProUGUI> ();
                if (tmpro == null)
                {
                    GameObject textGo      = text.gameObject;
                    Vector2    size        = textGo.GetComponent <RectTransform> ().sizeDelta;
                    string     displayText = text.text;
                    Color      textColor   = text.color;
                    float      fontSize    = (float)text.fontSize;
                    bool       italic      = text.fontStyle == FontStyle.Italic;
                    TextAnchor alignment   = text.alignment;
                    DestroyImmediate(text);

                    tmpro          = textGo.AddComponent <TextMeshProUGUI> ();
                    tmpro.text     = displayText;
                    tmpro.color    = textColor;
                    tmpro.fontSize = fontSize;
                    if (italic)
                    {
                        tmpro.fontStyle = FontStyles.Italic;
                    }
                    switch (alignment)
                    {
                    case TextAnchor.LowerCenter:
                        tmpro.alignment = TextAlignmentOptions.Bottom;
                        break;

                    case TextAnchor.LowerLeft:
                        tmpro.alignment = TextAlignmentOptions.BottomLeft;
                        break;

                    case TextAnchor.LowerRight:
                        tmpro.alignment = TextAlignmentOptions.BottomRight;
                        break;

                    case TextAnchor.MiddleCenter:
                        tmpro.alignment = TextAlignmentOptions.Center;
                        break;

                    case TextAnchor.MiddleLeft:
                        tmpro.alignment = TextAlignmentOptions.Left;
                        break;

                    case TextAnchor.MiddleRight:
                        tmpro.alignment = TextAlignmentOptions.Right;
                        break;

                    case TextAnchor.UpperCenter:
                        tmpro.alignment = TextAlignmentOptions.Top;
                        break;

                    case TextAnchor.UpperLeft:
                        tmpro.alignment = TextAlignmentOptions.TopLeft;
                        break;

                    case TextAnchor.UpperRight:
                        tmpro.alignment = TextAlignmentOptions.TopRight;
                        break;
                    }
                    tmpro.font = (TMP_FontAsset)AssetDatabase.LoadAssetAtPath("Assets/Textures and Sprites/Roboto-Medium SDF.asset", typeof(TMP_FontAsset));
                    textGo.GetComponent <RectTransform> ().sizeDelta = size;
                }
            }
        }
    }
コード例 #40
0
    public void CreateGameObjectTextZone(string GameObjectName, GameObject GameObjectParent, bool isAnchoredToParent, float SizeDeltaX, float SizeDeltaY,
                                         float AnchoredPositionX, float AnchoredPositionY, string text, Font font, TextAnchor textAnchor,
                                         FontStyle fontStyle, int FontSize, Color TextColor)
    {
        GameObject gameobject = new GameObject(GameObjectName);

        gameobject.AddComponent <RectTransform>();
        gameobject.transform.SetParent(GameObjectParent.transform, isAnchoredToParent);
        gameobject.GetComponent <RectTransform>().sizeDelta        = new Vector2(SizeDeltaX, SizeDeltaY);
        gameobject.GetComponent <RectTransform>().anchoredPosition = new Vector2(AnchoredPositionX, AnchoredPositionY);
        gameobject.AddComponent <Text>();
        gameobject.GetComponent <Text>().text             = text;
        gameobject.GetComponent <Text>().font             = font;
        gameobject.GetComponent <Text>().verticalOverflow = VerticalWrapMode.Overflow;
        gameobject.GetComponent <Text>().alignment        = textAnchor;
        gameobject.GetComponent <Text>().fontStyle        = fontStyle;
        gameobject.GetComponent <Text>().fontSize         = FontSize;
        gameobject.GetComponent <Text>().color            = TextColor;
    }
コード例 #41
0
ファイル: Grid.cs プロジェクト: Da11oS/My-second-game
    private TextMesh GetTextMesh(string text, Vector3 localPosition, int fontSize, Color color, TextAnchor textAnchor, int sortingOrder)
    {
        GameObject gameObject = new GameObject("World_text", typeof(TextMesh));

        gameObject.transform.localPosition = localPosition;
        TextMesh textMesh = gameObject.GetComponent <TextMesh>();

        textMesh.text     = text;
        textMesh.anchor   = textAnchor;
        textMesh.fontSize = fontSize;
        textMesh.color    = color;
        textMesh.GetComponent <MeshRenderer>().sortingOrder = sortingOrder;
        return(textMesh);
    }
コード例 #42
0
        public static TextMesh CreateWorldText(Transform parent, string text, Vector3 localPosition, int fontSize, Color color, TextAnchor textAnchor, TextAlignment textAlignment, int sortingOrder)
        {
            GameObject gameObject = new GameObject("World_Text", typeof(TextMesh));
            Transform  transform  = gameObject.transform;

            transform.SetParent(parent, false);
            transform.localPosition = localPosition;
            TextMesh textMesh = gameObject.GetComponent <TextMesh>();

            textMesh.anchor    = textAnchor;
            textMesh.alignment = textAlignment;
            textMesh.text      = text;
            textMesh.fontSize  = fontSize;
            textMesh.color     = color;
            textMesh.GetComponent <MeshRenderer>().sortingOrder = sortingOrder;
            return(textMesh);
        }
コード例 #43
0
ファイル: VBoxWidget.cs プロジェクト: cemuka/uFrame
 public void SetChildOrientation(TextAnchor textAnchor)
 {
     layout.childAlignment = textAnchor;
 }
コード例 #44
0
 public static GameObject CreateWorldText(Transform parent, string text, Vector3 localPosition, int fontSize, Color color, TextAnchor textAnchor, TextAlignment textAlignment, int sortingOrder)
 {
     if (LC_Utils.IsBuildForProduction())
     {
         return(LC_Utils.GetDeafultEmptyObject()); // Do nothing
     }
     return(LC_GraphicsDebugUtils.CreateWorldText(parent, text, localPosition, fontSize, color, textAnchor, textAlignment, sortingOrder).gameObject);
 }
コード例 #45
0
        private static GUIStyle CreateStyle(Color?color = null, int fontSize = -1, RectOffset padding = null, RectOffset border = null, Vector2?contentOffset = null, TextAnchor alignment = TextAnchor.MiddleLeft,
                                            Texture2D backgroundTexture = null, bool worldWrap = true, GUIStyle baseStyle = null)
        {
            GUIStyle style = null;

            if (baseStyle == null)
            {
                style = new GUIStyle();
            }
            else
            {
                style = new GUIStyle(baseStyle);
            }
            if (color != null)
            {
                style.normal.textColor    = color.Value;
                style.active.textColor    = color.Value;
                style.hover.textColor     = color.Value;
                style.focused.textColor   = color.Value;
                style.onActive.textColor  = color.Value;
                style.onFocused.textColor = color.Value;
                style.onActive.textColor  = color.Value;
                style.onNormal.textColor  = color.Value;
            }
            style.alignment = alignment;
            if (fontSize != -1)
            {
                style.fontSize = fontSize;
            }
            if (padding != null)
            {
                style.padding = padding;
            }
            if (border != null)
            {
                style.border = border;
            }
            if (contentOffset != null)
            {
                style.contentOffset = contentOffset.Value;
            }
            if (backgroundTexture != null)
            {
                style.normal.background    = backgroundTexture;
                style.active.background    = backgroundTexture;
                style.hover.background     = backgroundTexture;
                style.focused.background   = backgroundTexture;
                style.onActive.background  = backgroundTexture;
                style.onFocused.background = backgroundTexture;
                style.onHover.background   = backgroundTexture;
                style.onNormal.background  = backgroundTexture;
            }
            style.wordWrap = worldWrap;
            return(style);
        }
コード例 #46
0
ファイル: traitWindowFC.cs プロジェクト: Swatacular/Empire
        public override void DoWindowContents(Rect inRect)
        {
            //grab before anchor/font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;

            Text.Font   = GameFont.Medium;
            Text.Anchor = TextAnchor.UpperCenter;

            Widgets.Label(new Rect(0, 0, InitialSize.x, 30), "FactionPoliciesAndTraits".Translate());

            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(new Rect(xoffset, yoffset - 20, length, 25), "TaxLaw".Translate());
            Widgets.Label(new Rect(xoffset + (xspacing + length) * 1, yoffset - 20, length, 25), "SocialPolicy".Translate());
            Widgets.Label(new Rect(xoffset + (xspacing + length) * 2, yoffset - 20, length, 25), "MilitaryPolicy".Translate());

            Text.Font = GameFont.Tiny;
            for (int i = 0; i < 3; i++)             //from first trait to third
            {
                int basex = xoffset + (xspacing + length) * i;
                int basey = yoffset;
                Widgets.DrawMenuSection(new Rect(basex, basey, length, height));
                Widgets.DrawMenuSection(new Rect(basex, basey, (length / 4) * 3, height / 4));
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(new Rect(basex + 3, basey, (length / 4) * 3, height / 4), returnPolicies()[i].label);
                Text.Anchor = TextAnchor.UpperLeft;
                Widgets.Label(new Rect(basex + 3, basey + 3 + height / 4, length, (height / 4) * 3 - 3), returnPolicies()[i].desc);
                if (Widgets.ButtonInvisible(new Rect(basex, basey, length, height)))
                {                 //if click on policy
                    Find.WindowStack.Add(new listFactionPolicyFC(returnPolicies()[i], i, "EnactPolicy".Translate()));
                }
            }


            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(new Rect(xoffset, yoffset - 20 + height + yspacing, length, 25), "FactionTraits".Translate());

            Text.Font = GameFont.Tiny;
            for (int i = 0; i < 3; i++)             //from fourth to sixth
            {
                int basex = xoffset + (xspacing + length) * i;
                int basey = yoffset + yspacing + height;
                Widgets.DrawMenuSection(new Rect(basex, basey, length, height));
                Widgets.DrawMenuSection(new Rect(basex, basey, (length / 4) * 3, height / 4));
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(new Rect(basex + 3, basey, (length / 4) * 3, height / 4), returnPolicies()[i + 3].label);
                Text.Anchor = TextAnchor.UpperLeft;
                Widgets.Label(new Rect(basex + 3, basey + 3 + height / 4, length, (height / 4) * 3 - 3), returnPolicies()[i + 3].desc);
                if (Widgets.ButtonInvisible(new Rect(basex, basey, length, height)))
                {                 //if click on policy
                    Find.WindowStack.Add(new listFactionPolicyFC(returnPolicies()[(i + 3)], (i + 3), "AddTrait".Translate()));
                }
            }



            //reset anchor/font
            Text.Font   = fontBefore;
            Text.Anchor = anchorBefore;
        }
コード例 #47
0
        /// <summary>
        /// Draw the dialog region.
        /// </summary>
        protected override void Draw(Rect region)
        {
            TextAnchor anchor = GUI.skin.label.alignment;

            GUI.skin.label.alignment = TextAnchor.MiddleCenter;

            GUILayout.BeginArea(region);

            // Year
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            GUILayout.FlexibleSpace();

            if (GUILayout.Button(ScrollLeft, EditorStyles.toolbarButton))
            {
                time = time.AddYears(-1);
            }

            int year = EditorGUILayout.IntField(time.Year, EditorStyles.toolbarTextField, GUILayout.Width(100));

            if (year != time.Year)
            {
                time = new DateTime(year, time.Month, time.Day, time.Hour, time.Minute, time.Second);
            }

            if (GUILayout.Button(ScrollRight, EditorStyles.toolbarButton))
            {
                time = time.AddYears(1);
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            // Month
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            GUILayout.FlexibleSpace();

            if (GUILayout.Button(ScrollLeft, EditorStyles.toolbarButton))
            {
                time = time.AddMonths(-1);
            }

            int dayCount = DateTime.DaysInMonth(time.Year, time.Month);
            int selected = EditorGUILayout.Popup(time.Month - 1, months, EditorStyles.toolbarPopup, GUILayout.Width(108)) + 1;

            dayCount = DateTime.DaysInMonth(time.Year, selected);
            if (selected != time.Month)
            {
                time = new DateTime(time.Year, selected, Mathf.Clamp(time.Day, 1, dayCount), time.Hour, time.Minute, time.Second);
            }

            if (GUILayout.Button(ScrollRight, EditorStyles.toolbarButton))
            {
                time = time.AddMonths(1);
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            // Day
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            GUILayout.FlexibleSpace();

            GUILayout.Label("S", GUILayout.Width(32));
            GUILayout.Label("M", GUILayout.Width(32));
            GUILayout.Label("T", GUILayout.Width(32));
            GUILayout.Label("W", GUILayout.Width(32));
            GUILayout.Label("T", GUILayout.Width(32));
            GUILayout.Label("F", GUILayout.Width(32));
            GUILayout.Label("S", GUILayout.Width(32));

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            DayOfWeek day       = new DateTime(time.Year, time.Month, 1).DayOfWeek;
            int       dayNumber = 1;
            int       empty     = (int)day;
            int       row       = 0;

            while (row < 6)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                for (int d = 0; d < 7; d++)
                {
                    if (empty > 0)
                    {
                        GUILayout.Label("", GUILayout.Width(32));
                        empty--;
                    }
                    else if (dayCount <= 0)
                    {
                        GUILayout.Label("", GUILayout.Width(32));
                    }
                    else
                    {
                        if (GUILayout.Toggle((dayNumber == time.Day), dayNumber.ToString(), EditorStyles.miniButton, GUILayout.Width(32)))
                        {
                            time = new DateTime(time.Year, time.Month, dayNumber, time.Hour, time.Minute, time.Second);
                        }

                        dayNumber++;
                        dayCount--;
                    }
                }
                row++;
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
            }

            GUI.skin.label.alignment = TextAnchor.MiddleRight;

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Hour", GUILayout.Width(48));
            int hour = EditorGUILayout.IntSlider("", time.Hour, 0, 23);

            if (hour != time.Hour)
            {
                time = new DateTime(time.Year, time.Month, time.Day, hour, time.Minute, time.Second);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Minute", GUILayout.Width(48));
            int minute = EditorGUILayout.IntSlider("", time.Minute, 0, 59);

            if (minute != time.Minute)
            {
                time = new DateTime(time.Year, time.Month, time.Day, time.Hour, minute, time.Second);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Second", GUILayout.Width(48));
            int second = EditorGUILayout.IntSlider("", time.Second, 0, 59);

            if (second != time.Second)
            {
                time = new DateTime(time.Year, time.Month, time.Day, time.Hour, time.Minute, second);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Ok"))
            {
                Ok();
            }

            if (GUILayout.Button("Cancel"))
            {
                Cancel();
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.EndArea();

            GUI.skin.label.alignment = anchor;
        }
コード例 #48
0
 public StyledText(TextAnchor alignment)
 {
     this.alignment = alignment;
 }
コード例 #49
0
 /// <summary>
 /// OnResolve
 /// </summary>
 protected override void OnResolve()
 {
     enArrowAnchor = (TextAnchor)arrowAnchor;
 }
コード例 #50
0
        public override void DoWindowContents(Rect inRect)
        {
            //grab before anchor/font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;


            //Settlement Tax Collection Header
            Text.Anchor = TextAnchor.MiddleCenter;
            Text.Font   = GameFont.Small;

            Widgets.DrawMenuSection(menuSectionHeader);
            Widgets.DrawBox(menuSectionHeader);
            //Icon button
            if (Widgets.ButtonImage(headerFactionIcon, faction.factionIcon))
            {
            }

            Text.Anchor = TextAnchor.MiddleLeft;
            Text.Font   = GameFont.Medium;
            Widgets.Label(headerFactionName, faction.name);

            Text.Font = GameFont.Small;
            Widgets.Label(headerFactionTitle, faction.title);

            //Settings button
            if (Widgets.ButtonImage(headerSettings, TexLoad.iconCustomize))
            {
                Faction fact = FactionColonies.getPlayerColonyFaction();
                if (fact != null)
                {
                    Find.WindowStack.Add(new FactionCustomizeWindowFc(faction));
                }
            }


            //Progress bar

            Widgets.FillableBar(progressBarLevelUp, faction.factionXPCurrent / faction.factionXPGoal, foreground,
                                background, true);
            Widgets.DrawShadowAround(progressBarLevelUp);
            Text.Font   = GameFont.Tiny;
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(progressBarLevelUp, Math.Round(faction.factionXPCurrent) + "/" + faction.factionXPGoal);
            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.DrawBox(progressBarLevelUp);

            Text.Font = GameFont.Small;
            Widgets.Label(factionLevel, "FCLevel".Translate(faction.factionLevel));


            //Policies
            if (faction.policies.Count() == 2)
            {
                Widgets.ButtonImage(policy_1, faction.policies[0].def.IconLight);
                if (policy_1.Contains(Event.current.mousePosition))
                {
                    TooltipHandler.TipRegion(policy_1, returnPolicyText(faction.policies[0].def));
                }

                //Widgets.Label(policy_2, new GUIContent("test", "test test test"));
                Widgets.ButtonImage(policy_2, faction.policies[1].def.IconLight);
                if (policy_2.Contains(Event.current.mousePosition))
                {
                    TooltipHandler.TipRegion(policy_2, returnPolicyText(faction.policies[1].def));
                }
            }
            else
            {
                Widgets.Label(new Rect(policy_1.x, policy_1.y, 200, 50), "FCSelectYourTraits".Translate());
            }


            List <FloatMenuOption> list      = new List <FloatMenuOption>();
            List <FCPolicyDef>     available = availableTraitsList();

            //Trait)

            //TraitSlot
            if (Widgets.ButtonTextSubtle(trait_1, returnTraitAvailibility(1, faction.factionTraits[0]))) //CHANGE THIS
            {
                if (canChangeTrait(1, faction.factionTraits[0]))
                {
                    foreach (FCPolicyDef trait in available)
                    {
                        list.Add(new FloatMenuOption(trait.label, delegate
                        {
                            List <FloatMenuOption> confirm = new List <FloatMenuOption>();
                            confirm.Add(new FloatMenuOption("FCConfirmTrait".Translate(trait.label),
                                                            delegate { faction.factionTraits[0] = new FCPolicy(trait); }));
                            Find.WindowStack.Add(new FloatMenu(confirm));
                        },
                                                     mouseoverGuiAction: delegate
                        {
                            TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(100, 200)),
                                                     returnPolicyText(trait));
                        }));
                    }

                    Find.WindowStack.Add(new FloatMenu(list));
                }
            }

            if (Mouse.IsOver(trait_1) && faction.factionTraits[0].def != FCPolicyDefOf.empty)
            {
                TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(100, 200)),
                                         returnPolicyText(faction.factionTraits[0].def));
            }
            //End Trait Slot

            //TraitSlot
            if (Widgets.ButtonTextSubtle(trait_2, returnTraitAvailibility(2, faction.factionTraits[1]))) //CHANGE THIS
            {
                if (canChangeTrait(2, faction.factionTraits[1]))
                {
                    foreach (FCPolicyDef trait in available)
                    {
                        list.Add(new FloatMenuOption(trait.label, delegate
                        {
                            List <FloatMenuOption> confirm = new List <FloatMenuOption>();
                            confirm.Add(new FloatMenuOption("FCConfirmTrait".Translate(trait.label),
                                                            delegate { faction.factionTraits[1] = new FCPolicy(trait); }));
                            Find.WindowStack.Add(new FloatMenu(confirm));
                        },
                                                     mouseoverGuiAction: delegate
                        {
                            TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(200, 200)),
                                                     returnPolicyText(trait));
                        }));
                    }

                    Find.WindowStack.Add(new FloatMenu(list));
                }
            }

            if (Mouse.IsOver(trait_2) && faction.factionTraits[1].def != FCPolicyDefOf.empty)
            {
                TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(200, 200)),
                                         returnPolicyText(faction.factionTraits[1].def));
            }
            //End Trait Slot

            //TraitSlot
            if (Widgets.ButtonTextSubtle(trait_3, returnTraitAvailibility(3, faction.factionTraits[2]))) //CHANGE THIS
            {
                if (canChangeTrait(3, faction.factionTraits[2]))
                {
                    foreach (FCPolicyDef trait in available)
                    {
                        list.Add(new FloatMenuOption(trait.label, delegate
                        {
                            List <FloatMenuOption> confirm = new List <FloatMenuOption>();
                            confirm.Add(new FloatMenuOption("FCConfirmTrait".Translate(trait.label),
                                                            delegate { faction.factionTraits[2] = new FCPolicy(trait); }));
                            Find.WindowStack.Add(new FloatMenu(confirm));
                        },
                                                     mouseoverGuiAction: delegate
                        {
                            TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(300, 200)),
                                                     returnPolicyText(trait));
                        }));
                    }

                    Find.WindowStack.Add(new FloatMenu(list));
                }
            }

            if (Mouse.IsOver(trait_3) && faction.factionTraits[2].def != FCPolicyDefOf.empty)
            {
                TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(300, 200)),
                                         returnPolicyText(faction.factionTraits[2].def));
            }
            //End Trait Slot

            //TraitSlot
            if (Widgets.ButtonTextSubtle(trait_4, returnTraitAvailibility(4, faction.factionTraits[3]))) //CHANGE THIS
            {
                if (canChangeTrait(4, faction.factionTraits[3]))
                {
                    foreach (FCPolicyDef trait in available)
                    {
                        list.Add(new FloatMenuOption(trait.label, delegate
                        {
                            List <FloatMenuOption> confirm = new List <FloatMenuOption>();
                            confirm.Add(new FloatMenuOption("FCConfirmTrait".Translate(trait.label),
                                                            delegate { faction.factionTraits[3] = new FCPolicy(trait); }));
                            Find.WindowStack.Add(new FloatMenu(confirm));
                        },
                                                     mouseoverGuiAction: delegate
                        {
                            TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(400, 200)),
                                                     returnPolicyText(trait));
                        }));
                    }

                    Find.WindowStack.Add(new FloatMenu(list));
                }
            }

            if (Mouse.IsOver(trait_4) && faction.factionTraits[3].def != FCPolicyDefOf.empty)
            {
                TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(400, 200)),
                                         returnPolicyText(faction.factionTraits[3].def));
            }
            //End Trait Slot

            //TraitSlot
            if (Widgets.ButtonTextSubtle(trait_5, returnTraitAvailibility(5, faction.factionTraits[4]))) //CHANGE THIS
            {
                if (canChangeTrait(5, faction.factionTraits[4]))
                {
                    foreach (FCPolicyDef trait in available)
                    {
                        list.Add(new FloatMenuOption(trait.label, delegate
                        {
                            List <FloatMenuOption> confirm = new List <FloatMenuOption>();
                            confirm.Add(new FloatMenuOption("FCConfirmTrait".Translate(trait.label),
                                                            delegate { faction.factionTraits[4] = new FCPolicy(trait); }));
                            Find.WindowStack.Add(new FloatMenu(confirm));
                        },
                                                     mouseoverGuiAction: delegate
                        {
                            TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(500, 200)),
                                                     returnPolicyText(trait));
                        }));
                    }

                    Find.WindowStack.Add(new FloatMenu(list));
                }
            }

            if (Mouse.IsOver(trait_5) && faction.factionTraits[4].def != FCPolicyDefOf.empty)
            {
                TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(500, 200)),
                                         returnPolicyText(faction.factionTraits[4].def));
            }
            //End Trait Slot

            FactionFC fc = Find.World.GetComponent <FactionFC>();

            Widgets.Label(roadBuilding, "FCBuildRoads".Translate());
            Widgets.Checkbox(roadBuilding.x + roadBuilding.width + 5, roadBuilding.y,
                             ref fc.roadBuilder.roadBuildingEnabled);

            //SettlementBox


            Widgets.DrawMenuSection(settlementsBox);
            Text.Font   = GameFont.Tiny;
            Text.Anchor = TextAnchor.MiddleCenter;
            GUI.BeginGroup(settlementsBoxLabels);
            Widgets.DrawMenuSection(new Rect(0, 0, settlementsBox.width, 20));
            Widgets.DrawLightHighlight(new Rect(0, 0, settlementsBox.width, 20));
            Widgets.Label(settlement_1, "Name");
            if (Widgets.ButtonInvisible(settlement_1))
            {
                faction.settlements.Sort(FactionColonies.CompareSettlementName);
            }

            Widgets.Label(settlement_2, "Level");
            if (Widgets.ButtonInvisible(settlement_2))
            {
                faction.settlements.Sort(FactionColonies.CompareSettlementLevel);
            }

            Widgets.Label(settlement_3, "Mil Level");
            if (Widgets.ButtonInvisible(settlement_3))
            {
                faction.settlements.Sort(FactionColonies.CompareSettlementMilitaryLevel);
            }

            Widgets.Label(settlement_4, "Profit");
            if (Widgets.ButtonInvisible(settlement_4))
            {
                faction.settlements.Sort(FactionColonies.CompareSettlementProfit);
            }

            Widgets.Label(settlement_5, "Free Workers");
            if (Widgets.ButtonInvisible(settlement_5))
            {
                faction.settlements.Sort(FactionColonies.CompareSettlementFreeWorkers);
            }

            Widgets.Label(settlement_6, "Happiness");
            if (Widgets.ButtonInvisible(settlement_6))
            {
                faction.settlements.Sort(FactionColonies.CompareSettlementHappiness);
            }

            Widgets.Label(settlement_7, "Loyalty");
            if (Widgets.ButtonInvisible(settlement_7))
            {
                faction.settlements.Sort(FactionColonies.CompareSettlementLoyalty);
            }

            Widgets.Label(settlement_8, "Unrest");
            if (Widgets.ButtonInvisible(settlement_8))
            {
                faction.settlements.Sort(FactionColonies.CompareSettlementUnrest);
            }


            GUI.EndGroup();


            GUI.BeginGroup(settlementsBox);

            for (int i = 0; i < faction.settlements.Count(); i++)
            {
                SettlementFC settlement = faction.settlements[i];

                //settlement name
                if (Widgets.ButtonTextSubtle(AdjustRect(settlement_1, i), settlement.name))
                {
                    Find.WindowStack.Add(new SettlementWindowFc(settlement));
                }

                Text.Font   = GameFont.Tiny;
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(AdjustRect(settlement_2, i), settlement.settlementLevel.ToString());
                Widgets.Label(AdjustRect(settlement_3, i), settlement.settlementMilitaryLevel.ToString());
                Widgets.Label(AdjustRect(settlement_4, i), ((int)settlement.getTotalProfit()).ToString());
                Widgets.Label(AdjustRect(settlement_5, i), (settlement.workersUltraMax - settlement.getTotalWorkers()).ToString());
                Widgets.Label(AdjustRect(settlement_6, i), ((int)settlement.Happiness).ToString());
                Widgets.Label(AdjustRect(settlement_7, i), ((int)settlement.Loyalty).ToString());
                Widgets.Label(AdjustRect(settlement_8, i), ((int)settlement.Unrest).ToString());
            }

            GUI.EndGroup();


            //reset anchor/font
            Text.Font   = fontBefore;
            Text.Anchor = anchorBefore;

            if (Event.current.type == EventType.ScrollWheel)
            {
                scrollWindow(Event.current.delta.y);
            }
        }
コード例 #51
0
 public StyledText(TextAnchor alignment, float top, float down)
 {
     this.alignment = alignment;
     this.top       = top;
     this.down      = down;
 }
コード例 #52
0
            public TextContext(Factory f, Data data, Format.Text text)
            {
                m_factory = f;
                Format.TextProperty textProperty =
                    data.textProperties[text.textPropertyId];
                Format.Font fontProperty = data.fonts[textProperty.fontId];

                string fontName   = data.strings[fontProperty.stringId];
                float  fontHeight = (float)textProperty.fontHeight;
                float  width      = (float)text.width;

                m_height = (float)text.height;
#if !UNITY_4_5
                float lineSpacing = 1.0f + (float)textProperty.leading / fontHeight;
#endif
                //float letterSpacing = fontProperty.letterspacing;
                float leftMargin  = textProperty.leftMargin / fontHeight;
                float rightMargin = textProperty.rightMargin / fontHeight;

                var font = Resources.Load <Font>(fontName);
                if (font == null)
                {
                    font = Resources.GetBuiltinResource <Font>("Arial.ttf");
                }

                int        va         = textProperty.align & (int)Align.VERTICAL_MASK;
                int        a          = textProperty.align & (int)Align.ALIGN_MASK;
                TextAnchor textAnchor = TextAnchor.UpperLeft;
                switch (va)
                {
                default:
                    switch (a)
                    {
                    default:
                    case (int)Align.LEFT:
                        textAnchor = TextAnchor.UpperLeft;
                        break;

                    case (int)Align.RIGHT:
                        textAnchor = TextAnchor.UpperRight;
                        break;

                    case (int)Align.CENTER:
                        textAnchor = TextAnchor.UpperCenter;
                        break;
                    }
                    break;

                case (int)Align.VERTICAL_BOTTOM:
                    switch (a)
                    {
                    default:
                    case (int)Align.LEFT:
                        textAnchor = TextAnchor.LowerLeft;
                        break;

                    case (int)Align.RIGHT:
                        textAnchor = TextAnchor.LowerRight;
                        break;

                    case (int)Align.CENTER:
                        textAnchor = TextAnchor.LowerCenter;
                        break;
                    }
                    break;

                case (int)Align.VERTICAL_MIDDLE:
                    switch (a)
                    {
                    default:
                    case (int)Align.LEFT:
                        textAnchor = TextAnchor.MiddleLeft;
                        break;

                    case (int)Align.RIGHT:
                        textAnchor = TextAnchor.MiddleRight;
                        break;

                    case (int)Align.CENTER:
                        textAnchor = TextAnchor.MiddleCenter;
                        break;
                    }
                    break;
                }

                var s = new TextGenerationSettings();
#if UNITY_4_5
                s.anchor   = textAnchor;
                s.extents  = new Vector2(width - leftMargin - rightMargin, m_height);
                s.style    = FontStyle.Normal;
                s.size     = (int)fontHeight;
                s.wrapMode = TextWrapMode.Wrap;
#else
                s.textAnchor        = textAnchor;
                s.generationExtents =
                    new Vector2(width - leftMargin - rightMargin, m_height);
                s.fontStyle          = FontStyle.Normal;
                s.fontSize           = (int)fontHeight;
                s.lineSpacing        = lineSpacing;
                s.horizontalOverflow = HorizontalWrapMode.Wrap;
                s.verticalOverflow   = VerticalWrapMode.Overflow;
                s.scaleFactor        = 1.0f;
#endif
                s.color    = factory.ConvertColor(data.colors[text.colorId]);
                s.pivot    = new Vector2(-leftMargin, 0);
                s.richText = true;
                s.font     = font;
                m_textGenerationSettings = s;
            }
コード例 #53
0
ファイル: FontBatch3D.cs プロジェクト: Suceru/sc2.2mobile
        public void QueueText(string text, Vector3 position, Vector3 right, Vector3 down, Color color, TextAnchor anchor, Vector2 spacing)
        {
            Vector2 scale   = new Vector2(right.Length(), down.Length());
            Vector2 vector  = CalculateTextOffset(text, anchor, scale, spacing);
            Vector3 vector2 = position + vector.X * Vector3.Normalize(right) + vector.Y * Vector3.Normalize(down);
            Vector3 v       = vector2;

            right *= base.Font.Scale;
            down  *= base.Font.Scale;
            int num = 0;

            foreach (char c in text)
            {
                switch (c)
                {
                case '\n':
                    num++;
                    v = vector2 + (float)num * (base.Font.GlyphHeight + base.Font.Spacing.Y + spacing.Y) * down;
                    continue;

                case '\r':
                    continue;
                }
                BitmapFont.Glyph glyph = base.Font.GetGlyph(c);
                if (!glyph.IsBlank)
                {
                    Vector3 v2      = right * (glyph.TexCoord2.X - glyph.TexCoord1.X) * base.Font.Texture.Width;
                    Vector3 v3      = down * (glyph.TexCoord2.Y - glyph.TexCoord1.Y) * base.Font.Texture.Height;
                    Vector3 v4      = right * glyph.Offset.X + down * glyph.Offset.Y;
                    Vector3 v5      = v + v4;
                    Vector3 vector3 = v5 + v2;
                    Vector3 vector4 = v5 + v3;
                    Vector3 vector5 = v5 + v2 + v3;
                    int     count   = TriangleVertices.Count;
                    TriangleVertices.Count           += 4;
                    TriangleVertices.Array[count]     = new VertexPositionColorTexture(new Vector3(v5.X, v5.Y, v5.Z), color, new Vector2(glyph.TexCoord1.X, glyph.TexCoord1.Y));
                    TriangleVertices.Array[count + 1] = new VertexPositionColorTexture(new Vector3(vector3.X, vector3.Y, vector3.Z), color, new Vector2(glyph.TexCoord2.X, glyph.TexCoord1.Y));
                    TriangleVertices.Array[count + 2] = new VertexPositionColorTexture(new Vector3(vector5.X, vector5.Y, vector5.Z), color, new Vector2(glyph.TexCoord2.X, glyph.TexCoord2.Y));
                    TriangleVertices.Array[count + 3] = new VertexPositionColorTexture(new Vector3(vector4.X, vector4.Y, vector4.Z), color, new Vector2(glyph.TexCoord1.X, glyph.TexCoord2.Y));
                    int count2 = TriangleIndices.Count;
                    TriangleIndices.Count            += 6;
                    TriangleIndices.Array[count2]     = (ushort)count;
                    TriangleIndices.Array[count2 + 1] = (ushort)(count + 1);
                    TriangleIndices.Array[count2 + 2] = (ushort)(count + 2);
                    TriangleIndices.Array[count2 + 3] = (ushort)(count + 2);
                    TriangleIndices.Array[count2 + 4] = (ushort)(count + 3);
                    TriangleIndices.Array[count2 + 5] = (ushort)count;
                }
                v += right * (glyph.Width + base.Font.Spacing.X + spacing.X);
            }
        }
コード例 #54
0
        /// <summary>
        ///     Creates a TextRange object spanning the portion of 'startNode'
        ///     specified by 'locatorPart'.
        /// </summary>
        /// <param name="locatorPart">FixedTextRange locator part specifying start and end point of
        /// the TextRange</param>
        /// <param name="startNode">the FixedPage containing this locator part</param>
        /// <param name="attachmentLevel">set to AttachmentLevel.Full if the FixedPage for the locator
        /// part was found, AttachmentLevel.Unresolved otherwise</param>
        /// <returns>a TextRange spanning the text between start end end point in the FixedTextRange
        /// locator part
        /// , null if selection described by locator part could not be
        /// recreated</returns>
        /// <exception cref="ArgumentNullException">locatorPart or startNode are
        /// null</exception>
        /// <exception cref="ArgumentException">locatorPart is of the incorrect type</exception>
        /// <exception cref="ArgumentException">startNode is not a FixedPage</exception>
        /// <exception cref="ArgumentException">startNode does not belong to the DocumentViewer</exception>
        public override Object ResolveLocatorPart(ContentLocatorPart locatorPart, DependencyObject startNode, out AttachmentLevel attachmentLevel)
        {
            if (startNode == null)
            {
                throw new ArgumentNullException("startNode");
            }

            DocumentPage docPage = null;
            FixedPage    page    = startNode as FixedPage;

            if (page != null)
            {
                docPage = GetDocumentPage(page);
            }
            else
            {
                // If we were passed a DPV because we are walking the visual tree,
                // extract the DocumentPage from it;  its TextView will be used to
                // turn coordinates into text positions
                DocumentPageView dpv = startNode as DocumentPageView;
                if (dpv != null)
                {
                    docPage = dpv.DocumentPage as FixedDocumentPage;
                    if (docPage == null)
                    {
                        docPage = dpv.DocumentPage as FixedDocumentSequenceDocumentPage;
                    }
                }
            }

            if (docPage == null)
            {
                throw new ArgumentException(SR.Get(SRID.StartNodeMustBeDocumentPageViewOrFixedPage), "startNode");
            }

            if (locatorPart == null)
            {
                throw new ArgumentNullException("locatorPart");
            }

            attachmentLevel = AttachmentLevel.Unresolved;

            ITextView tv = (ITextView)((IServiceProvider)docPage).GetService(typeof(ITextView));

            Debug.Assert(tv != null);

            ReadOnlyCollection <TextSegment> ts = tv.TextSegments;

            //check first if a TextRange can be generated
            if (ts == null || ts.Count <= 0)
            {
                return(null);
            }

            TextAnchor resolvedAnchor = new TextAnchor();

            if (docPage != null)
            {
                string stringCount = locatorPart.NameValuePairs["Count"];
                if (stringCount == null)
                {
                    throw new ArgumentException(SR.Get(SRID.InvalidLocatorPart, TextSelectionProcessor.CountAttribute));
                }
                int count = Int32.Parse(stringCount, NumberFormatInfo.InvariantInfo);

                for (int i = 0; i < count; i++)
                {
                    // First we extract the start and end Point from the locator part.
                    Point start;
                    Point end;
                    GetLocatorPartSegmentValues(locatorPart, i, out start, out end);

                    //calulate start ITextPointer
                    ITextPointer segStart;
                    if (double.IsNaN(start.X) || double.IsNaN(start.Y))
                    {
                        //get start of the page
                        segStart = FindStartVisibleTextPointer(docPage);
                    }
                    else
                    {
                        //convert Point to TextPointer
                        segStart = tv.GetTextPositionFromPoint(start, true);
                    }

                    if (segStart == null)
                    {
                        //selStart can be null if there are no insertion points on this page
                        continue;
                    }

                    //calulate end ITextPointer
                    ITextPointer segEnd;
                    if (double.IsNaN(end.X) || double.IsNaN(end.Y))
                    {
                        segEnd = FindEndVisibleTextPointer(docPage);
                    }
                    else
                    {
                        //convert Point to TextPointer
                        segEnd = tv.GetTextPositionFromPoint(end, true);
                    }

                    //end TP can not be null when start is not
                    Invariant.Assert(segEnd != null, "end TP is null when start TP is not");

                    attachmentLevel = AttachmentLevel.Full;  // Not always true right?
                    resolvedAnchor.AddTextSegment(segStart, segEnd);
                }
            }

            if (resolvedAnchor.TextSegments.Count > 0)
            {
                return(resolvedAnchor);
            }
            else
            {
                return(null);
            }
        }
コード例 #55
0
 public NewAlignement(TextAnchor _alignment)
 {
     alignment = _alignment;
 }
コード例 #56
0
 private static void genTextSetting(out TextGenerationSettings settings, ref Font font, ref FontStyle style, ref int size, ref Color color, ref TextAnchor anchor)
 {
     settings = new TextGenerationSettings()
     {
         textAnchor           = anchor,
         color                = color,
         font                 = font,
         fontSize             = size,
         fontStyle            = style,
         verticalOverflow     = VerticalWrapMode.Overflow,
         horizontalOverflow   = HorizontalWrapMode.Overflow,
         alignByGeometry      = true,
         richText             = false,
         lineSpacing          = 1f,
         scaleFactor          = 1f,
         resizeTextForBestFit = false
     };
 }
コード例 #57
0
        static public void DrawText(Vector3 position, Quaternion rotation, string text, float size, TextAnchor text_anchor, Color color)
        {
            TextGenerationSettings settings = new TextGenerationSettings();

            settings.font      = GUI.skin.font;
            settings.color     = color;
            settings.fontStyle = FontStyle.Normal;

            settings.fontSize    = 32;
            settings.lineSpacing = 1.0f;
            settings.scaleFactor = 1.0f;
            settings.textAnchor  = text_anchor;

            settings.verticalOverflow    = VerticalWrapMode.Overflow;
            settings.horizontalOverflow  = HorizontalWrapMode.Overflow;
            settings.generateOutOfBounds = true;

            settings.font.material.SetPass(0);

            settings.CreateAndUseMesh(text, delegate(Mesh mesh) {
                Graphics.DrawMeshNow(
                    mesh,
                    Matrix4x4.TRS(
                        position,
                        rotation,
                        ((Vector2.one / settings.fontSize) * size).GetSpacar(1.0f)
                        )
                    );
            });
        }
コード例 #58
0
        public static bool DropDown(Rect position, GUIStyle style, string[] options, bool active, ref int currentOption)
        {
            if (!active)
            {
                GUI.color = inactiveColor;
            }
            else
            {
                GUI.color = activeColor;
            }
            TextAnchor anchor = style.alignment;

            style.alignment = TextAnchor.MiddleLeft;
            bool mouseHovers = false;

            HandleControlsCount();
            if (GUI.Button(position, options[currentOption], style))
            {
                if (active)
                {
                    controlStates[controlIndex] = !controlStates[controlIndex];
                }
            }
            style.alignment = anchor;
            GUI.Label(new Rect(position.x + position.width - 20, position.y, 20, position.height), "▼", style);
            if (controlStates[controlIndex] && active)
            {
                SceneView.RepaintAll();
                GUI.BeginGroup(new Rect(position.x, position.y + position.height, position.width, position.height * options.Length));
                GUI.backgroundColor = blackColor;
                GUI.Box(new Rect(0, 0, position.width, position.height * options.Length), "", whiteBox);
                if (new Rect(0, 0, position.width, position.height * options.Length).Contains(Event.current.mousePosition))
                {
                    mouseHovers = true;
                }
                for (int i = 0; i < options.Length; i++)
                {
                    Rect current = new Rect(0, position.height * i, position.width, position.height);
                    if (current.Contains(Event.current.mousePosition))
                    {
                        GUI.backgroundColor = new Color(0.2f, 0.2f, 0.2f, 0.7f);
                    }
                    else
                    {
                        GUI.backgroundColor = Color.clear;
                    }
                    if (GUI.Button(current, options[i], dropdownItem))
                    {
                        currentOption = i;
                        controlStates[controlIndex] = false;
                    }
                }
                if (controlStates[controlIndex])
                {
                    if (Event.current.type == EventType.MouseDown)
                    {
                        controlStates[controlIndex] = false;
                    }
                }
                GUI.backgroundColor = Color.white;
                GUI.EndGroup();
            }
            controlIndex++;
            return(mouseHovers);
        }
コード例 #59
0
 public void SetChildAligment(TextAnchor p)
 {
     panel.GetComponent <VerticalLayoutGroup>().childAlignment = p;
 }
コード例 #60
0
 public static GameObject CreateWorldText(string text, Transform parent = null, Vector3 localPosition = default(Vector3), int fontSize = 40, Color?color = null, TextAnchor textAnchor = TextAnchor.UpperLeft, TextAlignment textAlignment = TextAlignment.Left, int sortingOrder = LC_Utils.sortingOrderDefault)
 {
     if (LC_Utils.IsBuildForProduction())
     {
         return(LC_Utils.GetDeafultEmptyObject()); // Do nothing
     }
     if (color == null)
     {
         color = Color.white;
     }
     return(LC_GraphicsDebugUtils.CreateWorldText(parent, text, localPosition, fontSize, color, textAnchor, textAlignment, sortingOrder).gameObject);
 }