コード例 #1
0
        public bool PopulateWithErrors(string str, TextGenerationSettings settings, GameObject context)
        {
            TextGenerationError textGenerationError = this.PopulateWithError(str, settings);
            bool result;

            if (textGenerationError == TextGenerationError.None)
            {
                result = true;
            }
            else
            {
                if ((textGenerationError & TextGenerationError.CustomSizeOnNonDynamicFont) != TextGenerationError.None)
                {
                    Debug.LogErrorFormat(context, "Font '{0}' is not dynamic, which is required to override its size", new object[]
                    {
                        settings.font
                    });
                }
                if ((textGenerationError & TextGenerationError.CustomStyleOnNonDynamicFont) != TextGenerationError.None)
                {
                    Debug.LogErrorFormat(context, "Font '{0}' is not dynamic, which is required to override its style", new object[]
                    {
                        settings.font
                    });
                }
                result = false;
            }
            return(result);
        }
コード例 #2
0
 private TextGenerationSettings ValidatedSettings(TextGenerationSettings settings)
 {
     if ((settings.font == null) || !settings.font.dynamic)
     {
         if ((settings.fontSize != 0) || (settings.fontStyle != FontStyle.Normal))
         {
             if (settings.font != null)
             {
                 object[] args = new object[] { settings.font.name };
                 Debug.LogWarningFormat(settings.font, "Font size and style overrides are only supported for dynamic fonts. Font '{0}' is not dynamic.", args);
             }
             settings.fontSize  = 0;
             settings.fontStyle = FontStyle.Normal;
         }
         if (settings.resizeTextForBestFit)
         {
             if (settings.font != null)
             {
                 object[] objArray2 = new object[] { settings.font.name };
                 Debug.LogWarningFormat(settings.font, "BestFit is only supported for dynamic fonts. Font '{0}' is not dynamic.", objArray2);
             }
             settings.resizeTextForBestFit = false;
         }
     }
     return(settings);
 }
コード例 #3
0
ファイル: Text.cs プロジェクト: CarlosHBC/UnityDecompiled
 /// <summary>
 /// <para>Convenience function to populate the generation setting for the text.</para>
 /// </summary>
 /// <param name="extents">The extents the text can draw in.</param>
 /// <returns>
 /// <para>Generated settings.</para>
 /// </returns>
 public TextGenerationSettings GetGenerationSettings(Vector2 extents)
 {
     TextGenerationSettings settings = new TextGenerationSettings {
         generationExtents = extents
     };
     if ((this.font != null) && this.font.dynamic)
     {
         settings.fontSize = this.m_FontData.fontSize;
         settings.resizeTextMinSize = this.m_FontData.minSize;
         settings.resizeTextMaxSize = this.m_FontData.maxSize;
     }
     settings.textAnchor = this.m_FontData.alignment;
     settings.alignByGeometry = this.m_FontData.alignByGeometry;
     settings.scaleFactor = this.pixelsPerUnit;
     settings.color = this.color;
     settings.font = this.font;
     settings.pivot = base.rectTransform.pivot;
     settings.richText = this.m_FontData.richText;
     settings.lineSpacing = this.m_FontData.lineSpacing;
     settings.fontStyle = this.m_FontData.fontStyle;
     settings.resizeTextForBestFit = this.m_FontData.bestFit;
     settings.updateBounds = false;
     settings.horizontalOverflow = this.m_FontData.horizontalOverflow;
     settings.verticalOverflow = this.m_FontData.verticalOverflow;
     return settings;
 }
コード例 #4
0
 static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.TextGenerationSettings o;
         o = new UnityEngine.TextGenerationSettings();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
コード例 #5
0
        private TextGenerationSettings ValidatedSettings(TextGenerationSettings settings)
        {
            if (settings.font != null && settings.font.dynamic)
            {
                return(settings);
            }

            if (settings.fontSize != 0 || settings.fontStyle != FontStyle.Normal)
            {
                if (settings.font != null)
                {
                    Debug.LogWarningFormat(settings.font, "Font size and style overrides are only supported for dynamic fonts. Font '{0}' is not dynamic.", settings.font.name);
                }
                settings.fontSize  = 0;
                settings.fontStyle = FontStyle.Normal;
            }

            if (settings.resizeTextForBestFit)
            {
                if (settings.font != null)
                {
                    Debug.LogWarningFormat(settings.font, "BestFit is only supported for dynamic fonts. Font '{0}' is not dynamic.", settings.font.name);
                }
                settings.resizeTextForBestFit = false;
            }
            return(settings);
        }
コード例 #6
0
 public float GetPreferredHeight(string str, TextGenerationSettings settings)
 {
     settings.verticalOverflow = VerticalWrapMode.Overflow;
     settings.updateBounds     = true;
     Populate(str, settings);
     return(rectExtents.height);
 }
コード例 #7
0
 public float GetPreferredWidth(string str, TextGenerationSettings settings)
 {
     settings.horizontalOverflow = HorizontalWrapMode.Overflow;
     settings.verticalOverflow   = VerticalWrapMode.Overflow;
     settings.updateBounds       = true;
     Populate(str, settings);
     return(rectExtents.width);
 }
コード例 #8
0
 private TextGenerationError PopulateWithError(string str, TextGenerationSettings settings)
 {
     if ((!this.m_HasGenerated || (str != this.m_LastString)) || !settings.Equals(this.m_LastSettings))
     {
         this.m_LastValid = this.PopulateAlways(str, settings);
     }
     return(this.m_LastValid);
 }
コード例 #9
0
 /// <summary>
 ///   <para>Will generate the vertices and other data for the given string with the given settings.</para>
 /// </summary>
 /// <param name="str">String to generate.</param>
 /// <param name="settings">Settings.</param>
 public bool Populate(string str, TextGenerationSettings settings)
 {
     if (this.m_HasGenerated && str == this.m_LastString && settings.Equals(this.m_LastSettings))
     {
         return(this.m_LastValid);
     }
     return(this.PopulateAlways(str, settings));
 }
コード例 #10
0
 static public int set_pivot(IntPtr l)
 {
     UnityEngine.TextGenerationSettings o = (UnityEngine.TextGenerationSettings)checkSelf(l);
     UnityEngine.Vector2 v;
     checkType(l, 2, out v);
     o.pivot = v;
     setBack(l, o);
     return(0);
 }
コード例 #11
0
 static public int set_richText(IntPtr l)
 {
     UnityEngine.TextGenerationSettings o = (UnityEngine.TextGenerationSettings)checkSelf(l);
     System.Boolean v;
     checkType(l, 2, out v);
     o.richText = v;
     setBack(l, o);
     return(0);
 }
コード例 #12
0
ファイル: TextGenerator.cs プロジェクト: Hengle/JellyTerain
 private TextGenerationError PopulateWithError(string str, TextGenerationSettings settings)
 {
     if (m_HasGenerated && str == m_LastString && settings.Equals(m_LastSettings))
     {
         return(m_LastValid);
     }
     m_LastValid = PopulateAlways(str, settings);
     return(m_LastValid);
 }
コード例 #13
0
 static public int set_fontSize(IntPtr l)
 {
     UnityEngine.TextGenerationSettings o = (UnityEngine.TextGenerationSettings)checkSelf(l);
     System.Int32 v;
     checkType(l, 2, out v);
     o.fontSize = v;
     setBack(l, o);
     return(0);
 }
コード例 #14
0
 static public int set_lineSpacing(IntPtr l)
 {
     UnityEngine.TextGenerationSettings o = (UnityEngine.TextGenerationSettings)checkSelf(l);
     System.Single v;
     checkType(l, 2, out v);
     o.lineSpacing = v;
     setBack(l, o);
     return(0);
 }
コード例 #15
0
 static public int set_horizontalOverflow(IntPtr l)
 {
     UnityEngine.TextGenerationSettings o = (UnityEngine.TextGenerationSettings)checkSelf(l);
     UnityEngine.HorizontalWrapMode     v;
     checkEnum(l, 2, out v);
     o.horizontalOverflow = v;
     setBack(l, o);
     return(0);
 }
コード例 #16
0
 static public int set_color(IntPtr l)
 {
     UnityEngine.TextGenerationSettings o = (UnityEngine.TextGenerationSettings)checkSelf(l);
     UnityEngine.Color v;
     checkType(l, 2, out v);
     o.color = v;
     setBack(l, o);
     return(0);
 }
コード例 #17
0
 static public int set_font(IntPtr l)
 {
     UnityEngine.TextGenerationSettings o = (UnityEngine.TextGenerationSettings)checkSelf(l);
     UnityEngine.Font v;
     checkType(l, 2, out v);
     o.font = v;
     setBack(l, o);
     return(0);
 }
コード例 #18
0
 static public int set_textAnchor(IntPtr l)
 {
     UnityEngine.TextGenerationSettings o = (UnityEngine.TextGenerationSettings)checkSelf(l);
     UnityEngine.TextAnchor             v;
     checkEnum(l, 2, out v);
     o.textAnchor = v;
     setBack(l, o);
     return(0);
 }
コード例 #19
0
ファイル: TextGenerator.cs プロジェクト: yowchap/MelonLoader
        public unsafe bool Populate(string str, TextGenerationSettings settings)
        {
            void **args = stackalloc void *[2];

            args[0] = (void *)UnityInternals.ManagedStringToInternal(str);
            args[1] = (void *)UnityInternals.object_unbox(UnityInternals.ObjectBaseToPtrNotNull(settings));
            IntPtr returnedException = default;
            IntPtr obj = UnityInternals.runtime_invoke(m_Populate, UnityInternals.ObjectBaseToPtrNotNull(this), args, ref returnedException);

            Il2CppException.RaiseExceptionIfNecessary(returnedException);
            return(*(bool *)UnityInternals.object_unbox(obj));
        }
コード例 #20
0
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.TextGenerationSettings o;
			o=new UnityEngine.TextGenerationSettings();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
コード例 #21
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.TextGenerationSettings o;
         o = new UnityEngine.TextGenerationSettings();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #22
0
        private bool PopulateAlways(string str, TextGenerationSettings settings)
        {
            this.m_LastString       = str;
            this.m_HasGenerated     = true;
            this.m_CachedVerts      = false;
            this.m_CachedCharacters = false;
            this.m_CachedLines      = false;
            this.m_LastSettings     = settings;
            TextGenerationSettings textGenerationSettings = this.ValidatedSettings(settings);

            this.m_LastValid = this.Populate_Internal(str, textGenerationSettings.font, textGenerationSettings.color, textGenerationSettings.fontSize, textGenerationSettings.scaleFactor, textGenerationSettings.lineSpacing, textGenerationSettings.fontStyle, textGenerationSettings.richText, textGenerationSettings.resizeTextForBestFit, textGenerationSettings.resizeTextMinSize, textGenerationSettings.resizeTextMaxSize, textGenerationSettings.verticalOverflow, textGenerationSettings.horizontalOverflow, textGenerationSettings.updateBounds, textGenerationSettings.textAnchor, textGenerationSettings.generationExtents, textGenerationSettings.pivot, textGenerationSettings.generateOutOfBounds, textGenerationSettings.alignByGeometry);
            return(this.m_LastValid);
        }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.TextGenerationSettings o;
         o=new UnityEngine.TextGenerationSettings();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
コード例 #24
0
// properties

// methods

    static bool TextGenerationSettings_Equals__TextGenerationSettings(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 1)
        {
            UnityEngine.TextGenerationSettings arg0    = (UnityEngine.TextGenerationSettings)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.TextGenerationSettings argThis = (UnityEngine.TextGenerationSettings)vc.csObj;                JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(argThis.Equals(arg0)));
            JSMgr.changeJSObj(vc.jsObjID, argThis);
        }

        return(true);
    }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.TextGenerationSettings o;
         o = new UnityEngine.TextGenerationSettings();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #26
0
 static public int GetGenerationSettings(IntPtr l)
 {
     try{
         UnityEngine.UI.Text self = (UnityEngine.UI.Text)checkSelf(l);
         UnityEngine.Vector2 a1;
         checkType(l, 2, out a1);
         UnityEngine.TextGenerationSettings ret = self.GetGenerationSettings(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #27
0
 static int QPYX_GetGenerationSettings_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 2);
         UnityEngine.UI.Text QPYX_obj_YXQP              = (UnityEngine.UI.Text)ToLua.CheckObject <UnityEngine.UI.Text>(L_YXQP, 1);
         UnityEngine.Vector2 QPYX_arg0_YXQP             = ToLua.ToVector2(L_YXQP, 2);
         UnityEngine.TextGenerationSettings QPYX_o_YXQP = QPYX_obj_YXQP.GetGenerationSettings(QPYX_arg0_YXQP);
         ToLua.PushValue(L_YXQP, QPYX_o_YXQP);
         return(1);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
コード例 #28
0
        private TextGenerationError PopulateWithError(string str, TextGenerationSettings settings)
        {
            TextGenerationError lastValid;

            if (this.m_HasGenerated && str == this.m_LastString && settings.Equals(this.m_LastSettings))
            {
                lastValid = this.m_LastValid;
            }
            else
            {
                this.m_LastValid = this.PopulateAlways(str, settings);
                lastValid        = this.m_LastValid;
            }
            return(lastValid);
        }
コード例 #29
0
 static void TextGenerationSettings_lineSpacing(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.TextGenerationSettings _this = (UnityEngine.TextGenerationSettings)vc.csObj;
         var result = _this.lineSpacing;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single arg0 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.TextGenerationSettings _this = (UnityEngine.TextGenerationSettings)vc.csObj;
         _this.lineSpacing = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
コード例 #30
0
 static void TextGenerationSettings_fontSize(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.TextGenerationSettings _this = (UnityEngine.TextGenerationSettings)vc.csObj;
         var result = _this.fontSize;
         JSApi.setInt32((int)JSApi.SetType.Rval, (System.Int32)(result));
     }
     else
     {
         System.Int32 arg0 = (System.Int32)JSApi.getInt32((int)JSApi.GetType.Arg);
         UnityEngine.TextGenerationSettings _this = (UnityEngine.TextGenerationSettings)vc.csObj;
         _this.fontSize = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
コード例 #31
0
 static void TextGenerationSettings_color(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.TextGenerationSettings _this = (UnityEngine.TextGenerationSettings)vc.csObj;
         var result = _this.color;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.Color arg0 = (UnityEngine.Color)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.TextGenerationSettings _this = (UnityEngine.TextGenerationSettings)vc.csObj;
         _this.color = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
コード例 #32
0
 static void TextGenerationSettings_generateOutOfBounds(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.TextGenerationSettings _this = (UnityEngine.TextGenerationSettings)vc.csObj;
         var result = _this.generateOutOfBounds;
         JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
     }
     else
     {
         System.Boolean arg0 = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
         UnityEngine.TextGenerationSettings _this = (UnityEngine.TextGenerationSettings)vc.csObj;
         _this.generateOutOfBounds = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
コード例 #33
0
 static int GetGenerationSettings(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.UI.Text obj              = (UnityEngine.UI.Text)ToLua.CheckObject(L, 1, typeof(UnityEngine.UI.Text));
         UnityEngine.Vector2 arg0             = ToLua.ToVector2(L, 2);
         UnityEngine.TextGenerationSettings o = obj.GetGenerationSettings(arg0);
         ToLua.PushValue(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #34
0
ファイル: ExampleClass.cs プロジェクト: pass86/Unity
 void Start()
 {
     TextGenerationSettings settings = new TextGenerationSettings();
     settings.textAnchor = TextAnchor.MiddleCenter;
     settings.color = Color.red;
     settings.generationExtents = extents;
     settings.pivot = Vector2.zero;
     settings.richText = true;
     settings.font = font;
     settings.fontSize = 32;
     settings.resizeTextMinSize = resizeTextMinSize;
     settings.resizeTextMaxSize = resizeTextMaxSize;
     settings.fontStyle = FontStyle.Normal;
     settings.verticalOverflow = VerticalWrapMode.Overflow;
     TextGenerator generator = new TextGenerator();
     generator.Populate("I am a string", settings);
     Debug.Log("I generated: " + generator.vertexCount + " verts!");
 }
コード例 #35
0
 private TextGenerationSettings ValidatedSettings(TextGenerationSettings settings)
 {
     if ((settings.font == null) || !settings.font.dynamic)
     {
         if ((settings.fontSize != 0) || (settings.fontStyle != FontStyle.Normal))
         {
             if (settings.font != null)
             {
                 object[] args = new object[] { settings.font.name };
                 Debug.LogWarningFormat(settings.font, "Font size and style overrides are only supported for dynamic fonts. Font '{0}' is not dynamic.", args);
             }
             settings.fontSize = 0;
             settings.fontStyle = FontStyle.Normal;
         }
         if (settings.resizeTextForBestFit)
         {
             if (settings.font != null)
             {
                 object[] objArray2 = new object[] { settings.font.name };
                 Debug.LogWarningFormat(settings.font, "BestFit is only supported for dynamic fonts. Font '{0}' is not dynamic.", objArray2);
             }
             settings.resizeTextForBestFit = false;
         }
     }
     return settings;
 }
コード例 #36
0
ファイル: ScrollTextView.cs プロジェクト: medchedli/VRUIDemo
    public void Start()
    {
        m_outputTextComponent = OutputText.GetComponent<Text>();
        m_outputScrollBar = OutputScrollBar.GetComponent<Scrollbar>();
        m_outputViewExtents = OutputScrollView.GetComponent<RectTransform>().rect.size;
        m_outputTextExtents = OutputText.GetComponent<RectTransform>().rect.size;
        m_outputTextSettings =
            m_outputTextComponent.GetGenerationSettings(m_outputTextExtents);

        m_outputScratchBuffer = new StringBuilder(TEXT_BUFFER_SIZE);
        m_outputLines = new LinkedList<string>();

        m_outputTextComponent.text = "";
    }
コード例 #37
0
ファイル: SevaText.cs プロジェクト: Satsuoni/CardGameTest
    public TextGenerationSettings GetGenerationSettings(Vector2 extents)
    {
        var settings = new TextGenerationSettings();

            settings.generationExtents = extents;
            if (font != null && font.dynamic)
            {
                settings.fontSize = m_FontData.fontSize;
                settings.resizeTextMinSize = m_FontData.minSize;
                settings.resizeTextMaxSize = m_FontData.maxSize;
            }

            // Other settings
            settings.textAnchor = m_FontData.alignment;
        settings.scaleFactor = pixelsPerUnit;

            settings.color = color;
            settings.font = font;
            settings.pivot = rectTransform.pivot;
            settings.richText = m_FontData.richText;
            settings.lineSpacing = m_FontData.lineSpacing;
            settings.fontStyle = m_FontData.fontStyle;
            settings.resizeTextForBestFit = m_FontData.bestFit;
            settings.updateBounds = false;
            settings.horizontalOverflow = m_FontData.horizontalOverflow;
            settings.verticalOverflow = m_FontData.verticalOverflow;

            return settings;
    }
コード例 #38
0
ファイル: Text.cs プロジェクト: NetherDrk/Eternal-Empire
 /// <summary>
 /// 
 /// <para>
 /// Convenience function to populate the generation setting for the text.
 /// </para>
 /// 
 /// </summary>
 /// <param name="extents">The extents the text can draw in.</param>
 /// <returns>
 /// 
 /// <para>
 /// Generated settings.
 /// </para>
 /// 
 /// </returns>
 public TextGenerationSettings GetGenerationSettings(Vector2 extents)
 {
   TextGenerationSettings generationSettings = new TextGenerationSettings();
   generationSettings.generationExtents = extents;
   if ((UnityEngine.Object) this.font != (UnityEngine.Object) null && this.font.dynamic)
   {
     generationSettings.fontSize = this.m_FontData.fontSize;
     generationSettings.resizeTextMinSize = this.m_FontData.minSize;
     generationSettings.resizeTextMaxSize = this.m_FontData.maxSize;
   }
   generationSettings.textAnchor = this.m_FontData.alignment;
   generationSettings.alignByGeometry = this.m_FontData.alignByGeometry;
   generationSettings.scaleFactor = this.pixelsPerUnit;
   generationSettings.color = this.color;
   generationSettings.font = this.font;
   generationSettings.pivot = this.rectTransform.pivot;
   generationSettings.richText = this.m_FontData.richText;
   generationSettings.lineSpacing = this.m_FontData.lineSpacing;
   generationSettings.fontStyle = this.m_FontData.fontStyle;
   generationSettings.resizeTextForBestFit = this.m_FontData.bestFit;
   generationSettings.updateBounds = false;
   generationSettings.horizontalOverflow = this.m_FontData.horizontalOverflow;
   generationSettings.verticalOverflow = this.m_FontData.verticalOverflow;
   return generationSettings;
 }
コード例 #39
0
 /// <summary>
 /// <para>Will generate the vertices and other data for the given string with the given settings.</para>
 /// </summary>
 /// <param name="str">String to generate.</param>
 /// <param name="settings">Generation settings.</param>
 /// <param name="context">The object used as context of the error log message, if necessary.</param>
 /// <returns>
 /// <para>True if the generation is a success, false otherwise.</para>
 /// </returns>
 public bool PopulateWithErrors(string str, TextGenerationSettings settings, GameObject context)
 {
     TextGenerationError error = this.PopulateWithError(str, settings);
     if (error == TextGenerationError.None)
     {
         return true;
     }
     if ((error & TextGenerationError.CustomSizeOnNonDynamicFont) != TextGenerationError.None)
     {
         object[] args = new object[] { settings.font };
         Debug.LogErrorFormat(context, "Font '{0}' is not dynamic, which is required to override its size", args);
     }
     if ((error & TextGenerationError.CustomStyleOnNonDynamicFont) != TextGenerationError.None)
     {
         object[] objArray2 = new object[] { settings.font };
         Debug.LogErrorFormat(context, "Font '{0}' is not dynamic, which is required to override its style", objArray2);
     }
     return false;
 }
コード例 #40
0
 /// <summary>
 /// <para>Will generate the vertices and other data for the given string with the given settings.</para>
 /// </summary>
 /// <param name="str">String to generate.</param>
 /// <param name="settings">Settings.</param>
 public bool Populate(string str, TextGenerationSettings settings)
 {
     return (this.PopulateWithError(str, settings) == TextGenerationError.None);
 }
コード例 #41
0
		public bool Populate(string str, TextGenerationSettings settings)
		{
			if (this.m_HasGenerated && str == this.m_LastString && settings.Equals(this.m_LastSettings))
			{
				return this.m_LastValid;
			}
			return this.PopulateAlways(str, settings);
		}
コード例 #42
0
		private bool PopulateAlways(string str, TextGenerationSettings settings)
		{
			this.m_LastString = str;
			this.m_HasGenerated = true;
			this.m_CachedVerts = false;
			this.m_CachedCharacters = false;
			this.m_CachedLines = false;
			this.m_LastSettings = settings;
			TextGenerationSettings textGenerationSettings = this.ValidatedSettings(settings);
			this.m_LastValid = this.Populate_Internal(str, textGenerationSettings.font, textGenerationSettings.color, textGenerationSettings.fontSize, textGenerationSettings.lineSpacing, textGenerationSettings.fontStyle, textGenerationSettings.richText, textGenerationSettings.resizeTextForBestFit, textGenerationSettings.resizeTextMinSize, textGenerationSettings.resizeTextMaxSize, textGenerationSettings.verticalOverflow, textGenerationSettings.horizontalOverflow, textGenerationSettings.updateBounds, textGenerationSettings.textAnchor, textGenerationSettings.generationExtents, textGenerationSettings.pivot, textGenerationSettings.generateOutOfBounds);
			return this.m_LastValid;
		}
コード例 #43
0
 public bool Equals(TextGenerationSettings other)
 {
     return ((((((this.CompareColors(this.color, other.color) && (this.fontSize == other.fontSize)) && (Mathf.Approximately(this.scaleFactor, other.scaleFactor) && (this.resizeTextMinSize == other.resizeTextMinSize))) && (((this.resizeTextMaxSize == other.resizeTextMaxSize) && Mathf.Approximately(this.lineSpacing, other.lineSpacing)) && ((this.fontStyle == other.fontStyle) && (this.richText == other.richText)))) && ((((this.textAnchor == other.textAnchor) && (this.resizeTextForBestFit == other.resizeTextForBestFit)) && ((this.resizeTextMinSize == other.resizeTextMinSize) && (this.resizeTextMaxSize == other.resizeTextMaxSize))) && (((this.resizeTextForBestFit == other.resizeTextForBestFit) && (this.updateBounds == other.updateBounds)) && ((this.horizontalOverflow == other.horizontalOverflow) && (this.verticalOverflow == other.verticalOverflow))))) && (this.CompareVector2(this.generationExtents, other.generationExtents) && this.CompareVector2(this.pivot, other.pivot))) && (this.font == other.font));
 }
コード例 #44
0
ファイル: LRichText.cs プロジェクト: xmkp/uLui
        public void reloadData()
        {
            this.removeAllElements();

            RectTransform rtran = this.GetComponent<RectTransform>();
            //align
            if (alignType == RichAlignType.DESIGN_CENTER)
            {
                rtran.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f);

            }
            else if (alignType == RichAlignType.LEFT_TOP)
            {
                rtran.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
            }

            foreach (LRichElement elem in _richElements)
            {
                if (elem.type == RichType.TEXT)
                {
                    LRichElementText elemText = elem as LRichElementText;
                    char[] _charArr = elemText.txt.ToCharArray();
                    TextGenerator gen = new TextGenerator();

                    foreach (char strChar in _charArr)
                    {
                        LRenderElement rendElem = new LRenderElement();
                        rendElem.type = RichType.TEXT;
                        rendElem.strChar = strChar.ToString();
                        rendElem.isOutLine = elemText.isOutLine;
                        rendElem.isUnderLine = elemText.isUnderLine;
                        rendElem.font = this.font;
                        rendElem.fontSize = elemText.fontSize;
                        rendElem.data = elemText.data;
                        rendElem.color = elemText.color;

                        TextGenerationSettings setting = new TextGenerationSettings();
                        setting.font = this.font;
                        setting.fontSize = elemText.fontSize;
                        setting.lineSpacing = 1;
                        setting.scaleFactor = 1;
                        setting.verticalOverflow = VerticalWrapMode.Overflow;
                        setting.horizontalOverflow = HorizontalWrapMode.Overflow;

                        rendElem.width = (int)gen.GetPreferredWidth(rendElem.strChar, setting);
                        rendElem.height = (int)gen.GetPreferredHeight(rendElem.strChar, setting);
                        _elemRenderArr.Add(rendElem);
                    }
                }
                else if (elem.type == RichType.IMAGE)
                {
                    LRichElementImage elemImg = elem as LRichElementImage;
                    LRenderElement rendElem = new LRenderElement();
                    rendElem.type = RichType.IMAGE;
                    rendElem.path = elemImg.path;
                    rendElem.data = elemImg.data;
                    Sprite sp = LLoadBundle.GetInstance().LoadAsset(LGameConfig.WINDOW_BUNDLE, rendElem.path, typeof(Sprite)) as Sprite;
                    // Sprite sp = Resources.Load(rendElem.path,typeof(Sprite)) as Sprite;
                    rendElem.width = sp.texture.width;
                    rendElem.height = sp.texture.height;
                    _elemRenderArr.Add(rendElem);
                }
                else if (elem.type == RichType.ANIM)
                {
                    LRichElementAnim elemAnim = elem as LRichElementAnim;
                    LRenderElement rendElem = new LRenderElement();
                    rendElem.type = RichType.ANIM;
                    rendElem.path = elemAnim.path;
                    rendElem.data = elemAnim.data;
                    rendElem.fs = elemAnim.fs;

                    Sprite sp = LLoadBundle.GetInstance().LoadAsset(LGameConfig.WINDOW_BUNDLE, rendElem.path + "/1", typeof(Sprite)) as Sprite;
                    // Sprite sp = Resources.Load(rendElem.path+"/1",typeof(Sprite)) as Sprite;
                    rendElem.width = sp.texture.width;
                    rendElem.height = sp.texture.height;
                    _elemRenderArr.Add(rendElem);
                }
                else if (elem.type == RichType.NEWLINE)
                {
                    LRenderElement rendElem = new LRenderElement();
                    rendElem.isNewLine = true;
                    _elemRenderArr.Add(rendElem);
                }
            }

            _richElements.Clear();

            formarRenderers();
        }
コード例 #45
0
ファイル: DialogueBox.cs プロジェクト: luigivieira/Ze-do-Rego
    /// <summary>
    /// Calculates the text height with generator.
    /// 
    /// Usage example, the 0.6 is a default good value:		
    /// CalculateTextHeightWithGenerator(textContainerSize.rect.width,
    //                                         choice.dialogue,
    //                                         0.6f,
    //                                         btnText.font,
    //                                         btnText.fontSize,
    //                                         btnText.fontStyle);
    /// </summary>
    /// <returns>The text height with generator.</returns>
    /// <param name="maxWidth">Max width.</param>
    /// <param name="text">Text.</param>
    /// <param name="reducePercentage">Reduce percentage.</param>
    /// <param name="font">Font.</param>
    /// <param name="fontSize">Font size.</param>
    /// <param name="fontStyle">Font style.</param>
    private float CalculateTextHeightWithGenerator(float maxWidth, string text, 
	                                               float reducePercentage, Font font, 
	                                               int fontSize, FontStyle fontStyle)
    {
        TextGenerationSettings settings = new TextGenerationSettings();
        settings.textAnchor = TextAnchor.UpperLeft;
        settings.generationExtents = new Vector2(maxWidth, 0);
        settings.pivot = Vector2.zero;
        settings.richText = true;
        settings.lineSpacing = 0.1f;
        settings.font = font;
        settings.fontSize = fontSize;
        settings.fontStyle = fontStyle;
        settings.verticalOverflow = VerticalWrapMode.Overflow;
        TextGenerator generator = new TextGenerator();
        generator.Populate(text, settings);
        float height = generator.GetPreferredHeight(text, settings);

        return height * reducePercentage;
    }
コード例 #46
0
 private TextGenerationError PopulateAlways(string str, TextGenerationSettings settings)
 {
     TextGenerationError error;
     this.m_LastString = str;
     this.m_HasGenerated = true;
     this.m_CachedVerts = false;
     this.m_CachedCharacters = false;
     this.m_CachedLines = false;
     this.m_LastSettings = settings;
     TextGenerationSettings settings2 = this.ValidatedSettings(settings);
     this.Populate_Internal(str, settings2.font, settings2.color, settings2.fontSize, settings2.scaleFactor, settings2.lineSpacing, settings2.fontStyle, settings2.richText, settings2.resizeTextForBestFit, settings2.resizeTextMinSize, settings2.resizeTextMaxSize, settings2.verticalOverflow, settings2.horizontalOverflow, settings2.updateBounds, settings2.textAnchor, settings2.generationExtents, settings2.pivot, settings2.generateOutOfBounds, settings2.alignByGeometry, out error);
     this.m_LastValid = error;
     return error;
 }
コード例 #47
0
		public float GetPreferredHeight(string str, TextGenerationSettings settings)
		{
			settings.verticalOverflow = VerticalWrapMode.Overflow;
			settings.updateBounds = true;
			this.Populate(str, settings);
			return this.rectExtents.height;
		}
コード例 #48
0
 private TextGenerationError PopulateWithError(string str, TextGenerationSettings settings)
 {
     if ((!this.m_HasGenerated || (str != this.m_LastString)) || !settings.Equals(this.m_LastSettings))
     {
         this.m_LastValid = this.PopulateAlways(str, settings);
     }
     return this.m_LastValid;
 }
コード例 #49
0
		private TextGenerationSettings ValidatedSettings(TextGenerationSettings settings)
		{
			if (settings.font != null && settings.font.dynamic)
			{
				return settings;
			}
			if (settings.fontSize != 0 || settings.fontStyle != FontStyle.Normal)
			{
				Debug.LogWarning("Font size and style overrides are only supported for dynamic fonts.");
				settings.fontSize = 0;
				settings.fontStyle = FontStyle.Normal;
			}
			if (settings.resizeTextForBestFit)
			{
				Debug.LogWarning("BestFit is only suppoerted for dynamic fonts.");
				settings.resizeTextForBestFit = false;
			}
			return settings;
		}
コード例 #50
0
		/// <summary>
		/// Draw the Text.
		/// </summary>
		
		protected override void OnFillVBO(List<UIVertex> vbo)
		{
			if (font == null)
				return;

			Vector2 extents = rectTransform.rect.size;
			TextGenerationSettings settings = GetGenerationSettings(extents); 

			if (!m_cachedTextSettings.Equals( settings ) || m_cachedText != text)
			{
				base.OnFillVBO (vbo);

//				Debug.Log("TextSetting changed, updating verts! vbo.Count : " + vbo.Count); 

				// Update caches
				m_cachedVerts = vbo.GetRange(0, vbo.Count);
				m_cachedTextSettings = settings;
				m_cachedText = text;

				// Call to update animation letter setups
				m_animation_manager.UpdateText (text, new UGUITextDataHandler(m_cachedVerts), white_space_meshes: true);
			}
			else
			{
				// Use cached vert data
//				Debug.Log("Use cached vert data, m_cachedVerts[" + m_cachedVerts.Count + "] ");

				UIVertex new_vert;

				// Add each cached vert into the VBO buffer. Verts seem to need to be added one by one using Add(), can't just copy the list over
				for(int idx=0; idx < m_cachedVerts.Count; idx++)
				{
					vbo.Add(m_cachedVerts[idx]);

					if(Application.isPlaying && m_animation_manager.Playing && m_animation_manager.MeshVerts != null && idx < m_animation_manager.MeshVerts.Length)
					{
						new_vert = vbo[vbo.Count - 1];
						new_vert.position = m_animation_manager.MeshVerts[idx];
						new_vert.color = m_animation_manager.MeshColours[idx];
						vbo[vbo.Count - 1] = new_vert;

						m_forced_state_verts[idx] = m_animation_manager.MeshVerts[idx];
						m_forced_state_cols[idx] = m_animation_manager.MeshColours[idx];
					}
					else if(m_forced_state_verts != null && idx < m_forced_state_verts.Length)
					{
	//					Debug.Log("UGUI Using forced_state_verts");
						new_vert = vbo[vbo.Count - 1];
						new_vert.position = m_forced_state_verts[idx];
						new_vert.color = m_forced_state_cols[idx];
						vbo[vbo.Count - 1] = new_vert;
					}
				}

#if UNITY_EDITOR
				if(m_forced_state_verts != null)
				{
					// Set object dirty to trigger sceneview redraw/update. Calling SceneView.RepaintAll() doesn't work for some reason.
					EditorUtility.SetDirty( GameObject );
				}
#endif
			}
		}
コード例 #51
0
ファイル: lwf_unity_text.cs プロジェクト: DelSystem32/lwf
	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;
	}