Ejemplo n.º 1
0
        /// <summary>
        /// 拡張タグイベントを取得する
        /// </summary>
        public RichText.ExtraTagEvent[] GetExtraTagEvent(params string[] tFilter)
        {
            Vector2 tExtents = rectTransform.rect.size;
            RichTextGenerationSettings tSettings = GetRichTextGenerationSettings(tExtents);

            return(cachedTextGenerator.GetExtraTagEvent(text, tSettings, tFilter));
        }
Ejemplo n.º 2
0
/*		/// <summary>
 *              /// カーソルの位置を取得する
 *              /// </summary>
 *              public Vector2 cursorPosition
 *              {
 *                      get
 *          {
 *                              Vector2 tExtents = rectTransform.rect.size ;
 *                              RichTextGenerationSettings tSettings = GetRichTextGenerationSettings( tExtents ) ;
 *                              return cachedTextGenerator.GetCursorPosition( text, tSettings ) ;
 *                      }
 *
 *              }*/

        /// <summary>
        /// 指定した文字数のキャレットの座標を指定する
        /// </summary>
        /// <param name="tLength"></param>
        /// <returns></returns>
        public Vector2 GetCaretPosition(int tLength = -1)
        {
            Vector2 tExtents = rectTransform.rect.size;
            RichTextGenerationSettings tSettings = GetRichTextGenerationSettings(tExtents);

            return(cachedTextGenerator.GetCaretPosition(text, tSettings, tLength, startOffsetOfView, endOffsetOfView));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 指定したラインの終了時の描画対象となる文字数を取得する
        /// </summary>
        /// <param name="tLine"></param>
        /// <returns></returns>
        public int GetEndOffsetOfLine(int tLine)
        {
            if (cachedTextGenerator == null)
            {
                return(-1);
            }

            Vector2 tExtents = rectTransform.rect.size;
            RichTextGenerationSettings tSettings = GetRichTextGenerationSettings(tExtents);

            return(cachedTextGenerator.GetEndOffsetOfLine(text, tSettings, tLine));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// テキストジェネレータの設定を取得する
        /// </summary>
        /// <param name="extents"></param>
        /// <returns></returns>
        protected RichTextGenerationSettings GetRichTextGenerationSettings(Vector2 tExtents)
        {
            RichTextGenerationSettings tSettings = new RichTextGenerationSettings();

            tSettings.generationExtents = tExtents;
            tSettings.pivot             = rectTransform.pivot;

            tSettings.font               = font;
            tSettings.fontStyle          = fontData.fontStyle;
            tSettings.lineSpacing        = fontData.lineSpacing;
            tSettings.richText           = fontData.richText;
            tSettings.textAnchor         = fontData.alignment;
            tSettings.horizontalOverflow = fontData.horizontalOverflow;
            tSettings.verticalOverflow   = fontData.verticalOverflow;

            tSettings.resizeTextForBestFit = fontData.bestFit;

            tSettings.color = color;

            if (font != null)
            {
                tSettings.fontSize          = fontData.fontSize;
                tSettings.resizeTextMinSize = fontData.minSize;
                tSettings.resizeTextMaxSize = fontData.maxSize;
            }


            tSettings.scaleFactor  = pixelsPerUnit;
            tSettings.updateBounds = false;


            tSettings.viewControllEnabled = m_ViewControllEnabled;
            tSettings.lengthOfView        = m_LengthOfView;
            tSettings.startLineOfView     = m_StartLineOfView;
            tSettings.endLineOfView       = m_EndLineOfView;
            tSettings.startOffsetOfFade   = m_StartOffsetOfFade;
            tSettings.endOffsetOfFade     = m_EndOffsetOfFade;
            tSettings.ratioOfFade         = m_RatioOfFade;
            tSettings.widthOfFade         = m_WidthOfFade;

            tSettings.rubySizeScale       = m_RubySizeScale;
            tSettings.supOrSubSizeScale   = m_SupOrSubSizeScale;
            tSettings.topMarginSpacing    = m_TopMarginSpacing;
            tSettings.bottomMarginSpacing = m_BottomMarginSpacing;

            return(tSettings);
        }
Ejemplo n.º 5
0
        protected override void OnPopulateMesh(VertexHelper toFill)
        {
            if (font == null)
            {
                return;
            }

            // 以下テクスチャの作り直しを禁止する
            m_DisableFontTextureRebuiltCallback = true;

            //----------------------------------------------------------

            Vector2 tExtents = rectTransform.rect.size;
            RichTextGenerationSettings tSettings = GetRichTextGenerationSettings(tExtents);

            cachedTextGenerator.Populate(text, tSettings);

            // メッシュ全体の位置を調整する
            toFill.Clear();

            UIVertex[] vq = new UIVertex[4];

            UIVertex[] va = cachedTextGenerator.verts.ToArray();

            if (va != null && va.Length > 0)
            {
                int i, j, l = va.Length;
                for (i = 0; i < l; i = i + 4)
                {
                    for (j = 0; j < 4; j++)
                    {
                        vq[j] = va[i + j];
                    }

                    toFill.AddUIVertexQuad(vq);
                }
            }

            //----------------------------------------------------------

            // 以下テクスチャの作り直しを許可する
            m_DisableFontTextureRebuiltCallback = false;
        }
Ejemplo n.º 6
0
        public bool Equals(RichTextGenerationSettings other)
        {
#if false
            if (this.CompareVector2(this.generationExtents, other.generationExtents) == false)
            {
                Debug.LogWarning("generationExtents が異なる:" + this.generationExtents + " : " + other.generationExtents);
            }

            if (this.CompareVector2(this.pivot, other.pivot) == false)
            {
                Debug.LogWarning("pivot が異なる:" + this.pivot + " : " + other.pivot);
            }

            if (this.font != other.font)
            {
                Debug.LogWarning("font が異なる");
            }

            if (this.fontStyle != other.fontStyle)
            {
                Debug.LogWarning("fontStyle が異なる");
            }

            if (this.fontSize != other.fontSize)
            {
                Debug.LogWarning("fontSize が異なる");
            }

            if (Mathf.Approximately(this.lineSpacing, other.lineSpacing) == false)
            {
                Debug.LogWarning("lineSpacing が異なる");
            }

            if (this.richText != other.richText)
            {
                Debug.LogWarning("richText が異なる");
            }

            if (this.textAnchor != other.textAnchor)
            {
                Debug.LogWarning("textAnchor が異なる");
            }

            if (this.horizontalOverflow != other.horizontalOverflow)
            {
                Debug.LogWarning("horizontalOverflow が異なる");
            }

            if (this.verticalOverflow != other.verticalOverflow)
            {
                Debug.LogWarning("verticalOverflow が異なる");
            }

            if (this.resizeTextForBestFit != other.resizeTextForBestFit)
            {
                Debug.LogWarning("resizeTextForBestFit が異なる");
            }

            if (this.resizeTextMinSize != other.resizeTextMinSize)
            {
                Debug.LogWarning("resizeTextMinSize が異なる");
            }

            if (this.resizeTextMaxSize != other.resizeTextMaxSize)
            {
                Debug.LogWarning("resizeTextMaxSize が異なる");
            }

            if (this.CompareColors(this.color, other.color) == false)
            {
                Debug.LogWarning("color が異なる");
            }

            if (this.updateBounds != other.updateBounds)
            {
                Debug.LogWarning("updateBounds が異なる");
            }

            if (this.lengthOfView != other.lengthOfView)
            {
                Debug.LogWarning("lengthOfView が異なる");
            }

            if (this.startLineOfView != other.startLineOfView)
            {
                Debug.LogWarning("startLineOfView が異なる");
            }

            if (this.endLineOfView != other.endLineOfView)
            {
                Debug.LogWarning("endLineOfView が異なる");
            }

            if (Mathf.Approximately(this.rubySizeScale, other.rubySizeScale) == false)
            {
                Debug.LogWarning("rubySizeScale が異なる");
            }

            if (Mathf.Approximately(this.supOrSubSizeScale, other.supOrSubSizeScale) == false)
            {
                Debug.LogWarning("supOrSubSizeScale が異なる");
            }

            if (Mathf.Approximately(this.topMarginSpacing, other.topMarginSpacing) == false)
            {
                Debug.LogWarning("topMarginSpacing が異なる");
            }

            if (Mathf.Approximately(this.bottomMarginSpacing, other.bottomMarginSpacing) == false)
            {
                Debug.LogWarning("bottomMarginSpacing が異なる");
            }
#endif

            return
                (this.CompareVector2(this.generationExtents, other.generationExtents) == true &&
                 this.CompareVector2(this.pivot, other.pivot) == true &&
                 this.font == other.font &&
                 this.fontStyle == other.fontStyle &&
                 this.fontSize == other.fontSize &&
                 Mathf.Approximately(this.lineSpacing, other.lineSpacing) == true &&
                 this.richText == other.richText &&
                 this.textAnchor == other.textAnchor &&
                 this.horizontalOverflow == other.horizontalOverflow &&
                 this.verticalOverflow == other.verticalOverflow &&
                 this.resizeTextForBestFit == other.resizeTextForBestFit &&
                 this.resizeTextMinSize == other.resizeTextMinSize &&
                 this.resizeTextMaxSize == other.resizeTextMaxSize &&
                 this.CompareColors(this.color, other.color) == true &&
                 this.updateBounds == other.updateBounds &&

                 this.viewControllEnabled == other.viewControllEnabled &&
                 this.lengthOfView == other.lengthOfView &&
                 this.startLineOfView == other.startLineOfView &&
                 this.endLineOfView == other.endLineOfView &&
                 this.startOffsetOfFade == other.startOffsetOfFade &&
                 this.endOffsetOfFade == other.endOffsetOfFade &&
                 Mathf.Approximately(this.ratioOfFade, other.ratioOfFade) == true &&
                 this.widthOfFade == other.widthOfFade &&

                 Mathf.Approximately(this.rubySizeScale, other.rubySizeScale) == true &&
                 Mathf.Approximately(this.supOrSubSizeScale, other.supOrSubSizeScale) == true &&
                 Mathf.Approximately(this.topMarginSpacing, other.topMarginSpacing) == true &&
                 Mathf.Approximately(this.bottomMarginSpacing, other.bottomMarginSpacing) == true);
        }