UnityEngine.TextGenerator.GetPreferredWidth C# (CSharp) Method

GetPreferredWidth() public method

Given a string and settings, returns the preferred width for a container that would hold this text.

public GetPreferredWidth ( string str, TextGenerationSettings settings ) : float
str string Generation text.
settings TextGenerationSettings Settings for generation.
return float
        public float GetPreferredWidth(string str, TextGenerationSettings settings)
        {
            settings.horizontalOverflow = HorizontalWrapMode.Overflow;
            settings.verticalOverflow = VerticalWrapMode.Overflow;
            settings.updateBounds = true;
            this.Populate(str, settings);
            return this.rectExtents.width;
        }

Usage Example

コード例 #1
0
 static int GetPreferredWidth(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         UnityEngine.TextGenerator obj = (UnityEngine.TextGenerator)ToLua.CheckObject(L, 1, typeof(UnityEngine.TextGenerator));
         string arg0 = ToLua.CheckString(L, 2);
         UnityEngine.TextGenerationSettings arg1 = (UnityEngine.TextGenerationSettings)ToLua.CheckObject(L, 3, typeof(UnityEngine.TextGenerationSettings));
         float o = obj.GetPreferredWidth(arg0, arg1);
         LuaDLL.lua_pushnumber(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
All Usage Examples Of UnityEngine.TextGenerator::GetPreferredWidth