Vertical text display method and device based on vertex transformation

CN119067070APending Publication Date: 2024-12-03TUYOO GAMES +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411105691.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-13
Publication Date
2024-12-03

Smart Images

  • Figure CN119067070A_ABST
    Figure CN119067070A_ABST
Patent Text Reader

Abstract

The invention provides a vertical text display method and device based on vertex transformation, and the method comprises the steps: expanding a native Text component, obtaining a vertex of each text character in the component in the method for expanding the Text component, and changing the position of the vertex to obtain a preliminary vertical text; and further rotating the characters according to the special characters preset in the extended Text component, so that the display mode of the characters is suitable for a vertical text mode. Through the mode, when the vertical text is used in Unity, the vertical text and the original Text component have no difference, the vertical text is directly dragged to the node to be used, meanwhile, only characters with special display effects need to be concerned, all text contents do not need to be concerned, and the development efficiency is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a vertical text display method and device based on vertex transformation, a computing device, and a computer-readable storage medium. Background Art

[0002] In 3D applications, in applications developed using Unity, in addition to realizing regular text display, sometimes vertical text content needs to be displayed. The prior art generally adds a line break between two words for vertical display, but the method is not applicable to all texts. For example, the display of special characters is abnormal and the effect cannot be satisfied. It is necessary to pay attention to each character and insert a line break, which is inefficient. Therefore, there is an urgent need for an efficient, text-independent method for generating vertical text content. Summary of the invention

[0003] In view of this, the embodiments of the present application provide a vertical text display method and apparatus based on vertex transformation, a computing device, and a computer-readable storage medium to solve the technical defects existing in the prior art.

[0004] According to a first aspect of an embodiment of the present application, a vertical text display method based on vertex transformation is provided, comprising:

[0005] Create an extended Text component and override the OnPopulateMesh method in the extended Text component. The extended Text component inherits from the Text component.

[0006] In the OnPopulateMesh method, the input text of the extended Text component is obtained, and the vertex position of each text is transformed to obtain the first vertical text;

[0007] The preset characters in the first vertical text are rotated in situ to obtain a second vertical text.

[0008] According to a second aspect of an embodiment of the present application, a vertical text display device based on vertex transformation is provided, comprising:

[0009] A generation unit, used for creating an extended Text component and overriding an OnPopulateMesh method in the extended Text component, wherein the extended Text component inherits from the Text component;

[0010] A first conversion unit is used to obtain the input text of the extended Text component in the OnPopulateMesh method, and transform the vertex position of each text to obtain a first vertical text;

[0011] The second conversion unit is used to rotate the preset characters in the first vertical text in situ to obtain a second vertical text.

[0012] According to a third aspect of an embodiment of the present application, a computing device is provided, comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor implements the steps of the aforementioned method when executing the instructions.

[0013] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores computer instructions, and when the instructions are executed by a processor, the steps of the aforementioned method are implemented.

[0014] In the embodiment of the present application, the native Text component of the Unity development environment is expanded. In the related methods of the extended Text component, the vertices of each text character in the component are obtained, and the vertex positions are changed to obtain preliminary vertical text; then, according to the special characters pre-set in the extended Text component, these characters are further rotated so that the display mode of these characters is suitable for vertical text. In this way, when using vertical text in Unity, there is no difference from the native Text component. It can be directly dragged to the node for use. At the same time, you only need to care about the characters with special display effects, not all text content, which greatly improves the efficiency of development. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 is a structural block diagram of a computing device provided in an embodiment of the present application;

[0016] Figure 2 It is a flowchart of a vertical text display method based on vertex transformation provided in an embodiment of the present application;

[0017] Figure 3 is a schematic diagram of text displayed by the vertical text display method based on vertex transformation provided in an embodiment of the present application;

[0018] Figure 4 is another text schematic diagram displayed by the vertical text display method based on vertex transformation provided in an embodiment of the present application;

[0019] Figure 5 It is a structural schematic diagram of a vertical text display device based on vertex transformation provided in an embodiment of the present application. DETAILED DESCRIPTION

[0020] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.

[0021] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.

[0022] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "in response to determination".

[0023] In the present application, a vertical text display method and apparatus based on vertex transformation, a computing device and a computer-readable storage medium are provided, which are described in detail one by one in the following embodiments.

[0024] Figure 1 The structure block diagram of a computing device 100 according to an embodiment of the present application is shown. The components of the computing device 100 include but are not limited to a memory 110 and a processor 120. The processor 120 is connected to the memory 110 via a bus 130, and the database 150 is used to store data.

[0025] The computing device 100 also includes an access device 140 that enables the computing device 100 to communicate via one or more networks 160. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 140 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.

[0026] In one embodiment of the present application, the above components of the computing device 100 and Figure 1 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 1 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of the present application. Those skilled in the art may add or replace other components as needed.

[0027] The computing device 100 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 100 may also be a mobile or stationary server.

[0028] In the prior art, in a 3D development environment such as Unity, in some cases, text needs to be displayed vertically. The prior art usually uses line breaks or text rendering plug-ins such as TextMeshPro to achieve this. Using line breaks is inefficient and has poor effects. Using the TextMeshPro plug-in requires rich text rendering for each text content.<rotate=90> Mark, and then rotate the whole text, that is, for vertical text, the corresponding logic needs to be written manually each time, which is also inefficient. Therefore, a new vertical text display method is urgently needed to solve the above problems.

[0029] Therefore, in the embodiment of the present application, in order to solve the above problems, a vertical text display method based on vertex transformation is proposed for use in the Unity development environment, see Figure 2 , including steps 202 to 206.

[0030] Step 202: Create an extended Text component and override the OnPopulateMesh method in the extended Text component, which is inherited from the Text component.

[0031] In this step, in order to implement the vertical text function that the original Text component does not have, an extended Text component is created. The extended Text component inherits the Text component and overrides the native OnPopulateMesh method in the Text component.

[0032]

[0033]

[0034] Furthermore, a switch is set in the extended Text component. When the switch is turned on, the extended Text component displays vertical text, otherwise it displays horizontal text.

[0035] Step 204: In the OnPopulateMesh method, the input text of the extended Text component is obtained, and the vertex position of each text is transformed to obtain the first vertical text.

[0036] In this step, the text input in the extended Text component is obtained, and the vertices of each character in the text are obtained; further, the positions of these vertices are transformed, the x and y coordinate values ​​of the vertices are interchanged, and the sign of the y coordinate value is reversed, so that all vertices are rotated 90 degrees clockwise, and then the entire text is rotated clockwise, and the horizontal text is converted to vertical display to obtain the first vertical text, such as Figure 3 The sample code is as follows:

[0037] / / Each character consists of 6 vertices

[0038]

[0039] The original y coordinate, the new y coordinate becomes the negative value of the original x coordinate, achieving a 90-degree clockwise rotation of the vertex

[0040]

[0041] Step 206: In the OnPopulateMesh method, the preset characters in the first vertical text are rotated in situ to obtain a second vertical text.

[0042] In step 204, the conversion from horizontal text to vertical text is completed by changing the coordinates of the vertices. However, for some special symbols, such as Figure 3 The brackets "()" in the text do not meet the requirements of vertical text after rotation.

[0043] For such characters, they can be preset in the extended Text component. After step 204 is completed, the preset characters in the first vertical text are further processed to meet the requirements of the vertical text.

[0044] Specifically, further processing includes rotating the above-mentioned preset characters by a certain angle in situ so that they meet the requirements of the vertical problem, including the following steps:

[0045] Obtaining the center point position of a preset character in the first vertical text, and offsetting the positions of each vertex of the preset character relative to the center point position;

[0046] According to the rotation formula, rotate the offset vertex by a certain angle;

[0047] Finally, add the new position after rotation to the position of the center point to get the final position of the vertex, completing the rotation of the preset character.

[0048] The sample code is as follows:

[0049]

[0050]

[0051] For example, Figure 3 The brackets "()" in the first vertical text are rotated in situ to obtain the second vertical text, such as Figure 4 shown.

[0052] In the above-mentioned embodiment of the present application, in order to realize an efficient vertical text display solution in the Unity development environment, the native Text component is extended, and the vertex of each text character in the component is obtained in the relevant method, and the vertex position is changed to obtain a preliminary vertical text; then, according to the special characters pre-set in the extended Text component, these characters are further rotated so that the display method of these characters is suitable for the vertical text method. In this way, when using vertical text in Unity, there is no difference from the native Text component. It can be directly dragged to the node for use. At the same time, you only need to care about the characters with special display effects, not all text content, which greatly improves the development efficiency.

[0053] Corresponding to the above-mentioned vertical text display method embodiment based on vertex transformation, the present application also provides a vertical text display device embodiment based on vertex transformation, such as Figure 5 As shown, the device comprises:

[0054] A generation unit, used for creating an extended Text component and overriding an OnPopulateMesh method in the extended Text component, wherein the extended Text component inherits from the Text component;

[0055] A first conversion unit is used to obtain the input text of the extended Text component in the OnPopulateMesh method, and transform the vertex position of each text to obtain a first vertical text;

[0056] The second conversion unit is used to rotate the preset characters in the first vertical text in situ to obtain a second vertical text.

[0057] The above is a schematic scheme of a vertical text display device based on vertex transformation of this embodiment. It should be noted that the technical scheme of the device and the technical scheme of the vertical text display method based on vertex transformation mentioned above belong to the same concept, and the details of the technical scheme of the device that are not described in detail can be found in the description of the technical scheme of the vertical text display method based on vertex transformation mentioned above.

[0058] In one embodiment of the present application, a computing device is also provided, including a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein when the processor executes the instructions, the steps of the vertical text display method based on vertex transformation are implemented.

[0059] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the vertical text display method based on vertex transformation described above belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be found in the description of the technical scheme of the vertical text display method based on vertex transformation described above.

[0060] An embodiment of the present application further provides a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the vertical text display method based on vertex transformation as described above.

[0061] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the vertical text display method based on vertex transformation described above belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be found in the description of the technical scheme of the vertical text display method based on vertex transformation described above.

[0062] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0063] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0064] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0065] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0066] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the present application. The present application selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can understand and use the present application well. The present application is only limited by the claims and their full scope and equivalents.

Claims

1. A vertical text display method based on vertex transformation, used in Unity development environment, It is characterized in that include: Create an extended Text component and override the OnPopulateMesh method in the extended Text component. The extended Text component inherits from the Text component. In the OnPopulateMesh method, the input text of the extended Text component is obtained, and the vertex position of each text is transformed to obtain the first vertical text; The preset characters in the first vertical text are rotated in situ to obtain a second vertical text.

2. The method according to claim 1, in, The step of transforming the vertex position of each text includes: The x and y coordinates of the vertex are swapped and the sign of the y coordinate is reversed.

3. The method according to claim 1, in, The preset characters include: The characters pre-set in the extended Text component.

4. The method according to claim 1, in, Rotating the preset characters in the first vertical text in place includes: Obtaining a center point of a preset character in the first vertical text, and offsetting the positions of each vertex of the preset character relative to the center point; Rotate the offset vertices; Add the rotated vertex position to the center point position to get the final position of the preset character vertex.

5. The method according to claim 1, in, The extended Text component includes a switch. When the switch is turned on, the extended Text component displays vertical text, otherwise it displays horizontal text.

6. A vertical text display device based on vertex transformation, used in Unity development environment, It is characterized in that include: A generation unit, used for creating an extended Text component and overriding an OnPopulateMesh method in the extended Text component, wherein the extended Text component inherits from the Text component; A first conversion unit is used to obtain the input text of the extended Text component in the OnPopulateMesh method, and transform the vertex position of each text to obtain a first vertical text; The second conversion unit is used to rotate the preset characters in the first vertical text in situ to obtain a second vertical text.

7. A computing device comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, It is characterized in that When the processor executes the instructions, the steps of the method according to any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium storing computer instructions, It is characterized in that When the instruction is executed by a processor, the steps of the method described in any one of claims 1 to 5 are implemented.