示例#1
0
        public static Vector2 GetCursorPosition(TextNativeSettings settings, Rect rect, int cursorIndex)
        {
            if (settings.font == null)
            {
                Debug.LogError("Cannot process a null font.");
                return(Vector2.zero);
            }

            return(DoGetCursorPosition(settings, rect, cursorIndex));
        }
示例#2
0
        public static Vector2 GetOffset(TextNativeSettings settings, Rect screenRect)
        {
            if (settings.font == null)
            {
                Debug.LogError("Cannot process a null font.");
                return(new Vector2(0, 0));
            }

            settings.text = settings.text ?? "";

            return(DoGetOffset(settings, screenRect));
        }
示例#3
0
        public static unsafe NativeArray <TextVertex> GetVertices(TextNativeSettings settings)
        {
            int vertexCount = 0;

            GetVertices(settings, IntPtr.Zero, UnsafeUtility.SizeOf <TextVertex>(), ref vertexCount);
            var array = new NativeArray <TextVertex>(vertexCount, Allocator.Temp, NativeArrayOptions.UninitializedMemory);

            if (vertexCount > 0)
            {
                GetVertices(settings, (IntPtr)array.GetUnsafePtr(), UnsafeUtility.SizeOf <TextVertex>(), ref vertexCount);
                Debug.Assert(vertexCount == array.Length);
            }
            return(array);
        }
示例#4
0
        public static float ComputeTextHeight(TextNativeSettings settings)
        {
            if (settings.font == null)
            {
                Debug.LogError("Cannot process a null font.");
                return(0);
            }

            if (string.IsNullOrEmpty(settings.text))
            {
                return(0);
            }

            return(DoComputeTextHeight(settings));
        }
示例#5
0
 private static extern Vector2 DoGetOffset(TextNativeSettings settings, Rect rect);
示例#6
0
 private static extern void GetVertices(TextNativeSettings settings, IntPtr buffer, int vertexSize, ref int vertexCount);
示例#7
0
 private static extern Vector2 DoGetCursorPosition(TextNativeSettings settings, Rect rect, int cursorPosition);
示例#8
0
 private static extern float DoComputeTextHeight(TextNativeSettings settings);
示例#9
0
 private static extern float DoComputeTextWidth(TextNativeSettings settings);