Multi-terminal compatible UI collision and sorting detection method, device, equipment and medium
By using toolkits and scripts in the Unity editor, the problem of interactivity and compatibility of UI elements in multi-terminal environments is solved, cross-platform UI collision and sorting detection is achieved, and development efficiency and user experience are improved.
Patent Information
- Application Number
- CN202410939319.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-15
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-07-15
AI Technical Summary
In the existing technology, the interactivity of UI elements cannot be compatible with multiple terminals, and it is difficult to achieve efficient collision detection and sorting judgment, especially in a cross-platform environment.
Obtain the toolkit based on the Unity editor, create the root canvas and add the ImgPieDragManager script and collision detection script. Use the script to process the random shuffling and sorting detection of the elements to be sorted, and compare the parent node IDs in the preset correct order with the IDs of the elements to be sorted. , verify the correctness of sorting, and write drag and collision logic to realize drag and collision of elements.
It implements cross-platform UI collision and sorting detection, reduces developers' workload of repeatedly writing code, improves development efficiency, simplifies complexity, saves development costs, and provides a consistent user experience.
Smart Images

Figure CN118466958B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of virtual reality technology, and in particular to a multi-terminal compatible UI collision and sorting detection method, device, equipment and medium. Background Art
[0002] In interactive applications such as virtual reality (VR) and augmented reality (AR), the interactivity and operability of user interface (UI) elements are crucial. Currently, the implementation of UI elements is often limited by the technical platform, especially in terms of compatibility with multiple terminals and efficient collision detection and judgment sorting. It is impossible to use Unity UGUI (Unity Graphical User Interface) to achieve detection and sorting that can be used by multiple terminals (PC, mobile, VR). There are also various methods for implementing collision detection and sorting judgment, which are difficult to unify. Summary of the invention
[0003] In view of this, an embodiment of the present invention provides a multi-terminal compatible UI collision and sorting detection method to solve the technical problem that the interaction of UI elements in the prior art is not compatible with multiple terminals. The method includes:
[0004] Get a toolkit for cross-platform interactive applications based on the Unity Editor;
[0005] A root canvas for displaying the UGUI is created based on the toolkit, and a top-level parent UI for storing the elements to be sorted and the parent nodes of the elements to be sorted is created on the root canvas;
[0006] Add an ImgPieDragManager script to the top-level parent UI, where the ImgPieDragManager script is used to handle the random shuffling of the positions of the elements to be sorted, the relationship mapping between the elements to be sorted and the parent nodes, and the sorting detection of the elements to be sorted;
[0007] Add a parent node with a preset correct order to each element to be sorted and add it to the top-level parent UI, and add a script for collision detection to each element to be sorted;
[0008] Drag and drop the sorting elements and perform collision detection based on the script for collision detection;
[0009] Based on the ImgPieDragManager script, the elements to be sorted after collision detection are randomly shuffled;
[0010] Based on the ImgPieDragManager script, the shuffled IDs of the elements to be sorted are compared with the preset correct order of the parent nodes to perform sorting detection on the elements to be sorted.
[0011] The embodiment of the present invention also provides a multi-terminal compatible UI collision and sorting detection device to solve the technical problem that the interaction of UI elements in the prior art is not compatible with multiple terminals. The device includes:
[0012] Toolkit acquisition module, used to obtain toolkits for cross-platform interactive applications based on the Unity editor;
[0013] A root canvas creation module, used to create a root canvas for displaying UGUI based on the toolkit, and to create a top-level parent UI for storing the elements to be sorted and the parent nodes of the elements to be sorted on the root canvas;
[0014] A first script adding module is used to add an ImgPieDragManager script to the top-level parent UI, wherein the ImgPieDragManager script is used to process the random shuffling of the positions of the elements to be sorted, the relationship mapping between the elements to be sorted and the parent nodes, and the sorting detection of the elements to be sorted;
[0015] The second script adding module adds a parent node of a preset correct order to each element to be sorted and then adds it to the top-level parent UI, and adds a script for collision detection to each element to be sorted;
[0016] A collision detection module, used for dragging and collision detection of the elements to be sorted based on the script for collision detection;
[0017] An element shuffling module, used for randomly shuffling the elements to be sorted after collision detection based on the ImgPieDragManager script;
[0018] The sorting detection module is used to compare the shuffled IDs of the elements to be sorted with the preset correct order of the parent nodes based on the ImgPieDragManager script to perform sorting detection on the elements to be sorted.
[0019] An embodiment of the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the processor implements any of the above-mentioned multi-terminal compatible UI collision and sorting detection methods to solve the technical problem in the prior art that the interaction of UI elements is not compatible with multiple terminals.
[0020] An embodiment of the present invention further provides a computer-readable storage medium storing a computer program for executing any of the above-mentioned multi-terminal compatible UI collision and sorting detection methods to solve the technical problem in the prior art that the interaction of UI elements is not compatible with multiple terminals.
[0021] Compared with the prior art, the beneficial effects that can be achieved by at least one of the above-mentioned technical solutions adopted in the embodiments of this specification include at least: obtaining a toolkit for cross-platform interactive applications based on the Unity editor; creating a root canvas for displaying the UGUI, and creating a top-level parent UI for storing the elements to be sorted and the parent nodes of the elements to be sorted; adding the ImgPieDragManager script to the top-level parent UI; adding a parent node with a preset correct order to each element to be sorted and adding it to the top-level parent UI, and adding a script for collision detection to each element to be sorted; dragging and collision detection of the elements to be sorted based on the script for collision detection; randomly shuffling the elements to be sorted based on the ImgPieDragManager script; comparing the IDs of the shuffled elements to be sorted with the preset correct order of the parent nodes based on the ImgPieDragManager script, and performing sorting detection on the elements to be sorted. The method of the present application is based on a toolkit for cross-platform interactive applications built into the Unity editor. It compares the IDs of parent nodes in the correct order with the IDs of the elements to be sorted to verify whether the sorting is correct. At the same time, it uses the inheritance method of Unity's built-in scripts to write the required drag and collision logic to implement the dragging, transposition and collision of elements. This saves Unity developers from having to spend energy and time repeatedly writing collision detection and sorting detection functions, and also saves developers from having to write multiple versions of functions. It can help developers write once and have multiple terminals available, improve developer efficiency, simplify production complexity, and thus save development costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 is a flowchart of a multi-terminal compatible UI collision and sorting detection method provided by an embodiment of the present invention;
[0024] Figure 2 is a structural block diagram of a computer device provided by an embodiment of the present invention;
[0025] Figure 3 It is a structural block diagram of a multi-terminal compatible UI collision and sorting detection device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0026] The embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0027] The following describes the implementation methods of the present application through specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The present application can also be implemented or applied through other different specific implementation methods, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that, in the absence of conflict, the following embodiments and the features in the embodiments can be combined with each other. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work belong to the scope of protection of the present application.
[0028] In an embodiment of the present invention, a multi-terminal compatible UI collision and sorting detection method is provided, such as Figure 1 As shown, the method includes:
[0029] Step S101: obtaining a toolkit for a cross-platform interactive application based on the Unity editor;
[0030] Step S102: creating a root canvas for displaying the UGUI based on the toolkit, and creating a top-level parent UI for storing the elements to be sorted and the parent nodes of the elements to be sorted on the root canvas;
[0031] Step S103: adding an ImgPieDragManager script to the top-level parent UI, wherein the ImgPieDragManager script is used to process the random shuffling of the positions of the elements to be sorted, the relationship mapping between the elements to be sorted and the parent nodes, and the sorting detection of the elements to be sorted;
[0032] Step S104: adding a parent node of a preset correct order to each element to be sorted and then adding it to the top-level parent UI, and adding a script for collision detection to each element to be sorted;
[0033] Step S105: dragging and performing collision detection on the elements to be sorted based on the script for collision detection;
[0034] Step S106: Based on the ImgPieDragManager script, randomly shuffle the elements to be sorted after collision detection;
[0035] Step S107: Based on the ImgPieDragManager script, the IDs of the elements to be sorted after being shuffled are compared with the preset correct order of the parent nodes to perform sorting detection on the elements to be sorted.
[0036] The method of the present application is based on a toolkit for cross-platform interactive applications built into the Unity editor. It compares the IDs of parent nodes in the correct order with the IDs of the elements to be sorted to verify whether the sorting is correct. At the same time, it uses the inheritance method of Unity's built-in scripts to write the required drag and collision logic to implement the dragging, transposition and collision of elements. This saves Unity developers from having to spend energy and time repeatedly writing collision detection and sorting detection functions, and also saves developers from having to write multiple versions of functions. It can help developers write once and have multiple terminals available, improve developer efficiency, simplify production complexity, and thus save development costs.
[0037] In specific implementation, the toolkit for cross-platform interactive applications is XR Interaction Toolkit, which can be obtained by opening the Unity editor, clicking the Windows button, selecting the Package Manager option to open the interface, selecting the Unity Registry option, finding the XR Interaction Toolkit, and clicking the Install button to download and install it. XR Interaction Toolkit is a toolkit provided by Unity for developing cross-platform (such as VR, AR) interactive applications. It provides a series of functions and components to simplify the interaction design and implementation process of developers in these environments, such as input system integration, virtual handle interaction components, virtual user interface interaction, physical interaction, posture and gestures, interactive events, etc.
[0038] In one embodiment, the step of creating a root canvas for displaying a UGUI based on the toolkit includes:
[0039] In the Unity editor, based on the toolkit, a root canvas (Canvas) is created for displaying the UGUI, and the mode of the root canvas is changed to the world mode (WorldSpace);
[0040] Add an XR tracked device graphic raycaster built-in script (TrackedDeviceGraphicRaycaster) to the root canvas, and use the script to enable the elements to be sorted to be clicked and interacted with by rays.
[0041] By adding this script, the UI elements on the canvas can be clicked by virtual rays. All UI elements that need to be operated by handle rays in VR later need to be included under the Canvas to which the script is added.
[0042] In the specific implementation, the UI elements of Unity UGUI are used to create a top-level parent UI for storing the elements to be sorted and the parent nodes of the elements to be sorted, named Group. This group can be used to store the elements to be sorted and the parent nodes of the sorted elements. For ease of understanding, a simple example is used to explain each professional term: Assume a scene, first you need a room (root canvas, Canvas), then place a table (group) in the room, and place 10 cups (parent nodes of the sorting elements) on the table in order, each cup is numbered 0 to 9, and then put 10 ping-pong balls (sorting elements) on the table, each ball also has its own number 0 to 9. How to play: shuffle the balls and put them randomly into the cups, one ball for each cup, and then let the player put the balls with the same number into the corresponding cups in order. After placing them, compare and check whether the ball numbers in each cup are the same as the cups. If they are the same, it means the sorting is correct.
[0043] In one embodiment, in step S104, the script for collision detection includes an ImageCollision script, a BoxCollider script, a Rigidbody script and a CanvasGroup script, the ImageCollision script is used to process the collision, dragging and position exchange of the elements to be sorted, the BoxCollider script is used to define the collision volume and position of the elements to be sorted, the Rigidbody script is used to trigger collision events, and the CanvasGroup script is used to control the transparency of the elements to be sorted.
[0044] In specific implementation, the ImageCollision script first inherits the three methods of OnBeginDrag (the method for starting dragging), OnDrag (the method for dragging), and OnEndDrag (the method for ending dragging), in which the drag logic is written to enable the element to be dragged arbitrarily by the mouse and rays; then the OnTriggerEnter inherited method is implemented, in which the post-collision logic is written, and the position exchange is realized in conjunction with the drag method. The BoxCollider script is a collision volume script that defines the collision volume and position of the element; the Rigidbody script is a rigid body script, which is used to trigger collision events in this application, and is used together with BoxCollider to define that the element can be collided. Only elements with this script added can collide with other elements with BoxCollider added. The CanvasGroup script is used to control the transparency of the element. The transparency of the element is controlled by controlling the alpha property of this component (the alpha property is a range value for controlling transparency, 0 to 100, with a value of 0 for complete transparency, 50 for semi-transparency, and 100 for opacity), which is used to make the elements that need to be dragged semi-transparent and distinguish them from other exchangeable elements.
[0045] In the specific implementation, in step S104, adding a preset correct order to the parent node is achieved through the ImgParent script. The ImgParent script is used to define the real order. This script exposes an attribute for recording the ID of the real order of the parent node (the ID of the preset correct order). Finally, when judging whether the order is correct or not (sort detection), it is needed to compare it with the ID of the element to be sorted corresponding to each parent node.
[0046] In one embodiment, the method further comprises:
[0047] A temporary parent node is added to each of the elements to be sorted, and the temporary parent node enables the elements to be sorted to be displayed on the top layer when being dragged.
[0048] In a specific implementation, after the temporary parent node is added, when the element to be sorted is dragged, it can be added to the temporary parent node, so that the element to be sorted is displayed on the top layer.
[0049] In one embodiment, before the step of dragging and collision detection on the elements to be sorted based on the script for collision detection, the method further includes:
[0050] Sorting content is added to each of the elements to be sorted, and the sorting content includes text, pictures and videos.
[0051] In specific implementation, images can be added to the elements to be sorted for image sorting, such as puzzles; texts can also be added to the elements to be sorted for text sorting, such as operation steps, drag sorting, etc.
[0052] In one embodiment, the method further comprises:
[0053] The btn attribute of the ImgPieDragManager script is set with a first component, where the first component is used to randomly shuffle the elements to be sorted after being clicked;
[0054] The btnCheck property of the ImgPieDragManager script is set with a second component, where the second component is used to perform sorting detection on the elements to be sorted after being clicked.
[0055] In this embodiment, the btn attribute (button attribute) is used to store a reference to a button component in the UI framework. The btn attribute serves as a connection point between the user interface and the backend logic in the ImgPieDragManager script, allowing users to randomly shuffle the elements to be sorted through simple click operations, thereby providing an intuitive user interaction method; the btnCheck attribute (button check attribute) is also used to store a reference to the button component in the UI framework. The btnCheck attribute serves as a bridge between the UI and the logic in the ImgPieDragManager script, allowing users to trigger the sorting detection process through interactive operations. The operation associated with the btn attribute tends to change the state or reset, while the btnCheck attribute is more used to evaluate the correctness of the current state. Although both the btn and btnCheck attributes store references to the button component in the UI framework, the event handlers they are bound to (i.e., the method executed after clicking) will execute completely different logics. Re-shuffling and submission judgments are realized by adding two button components, i.e., the first component is used to re-shuffle the order of the elements to be sorted after being clicked, and the second component is used to verify whether the sorting of the elements to be sorted is correct after being clicked (sorting detection).
[0056] The following describes a method for detecting UI collision and sorting that is compatible with multiple terminals, taking a specific setting process as an example, which specifically includes the following steps:
[0057] 1. Import the XR Interaction Toolkit built-in toolkit in the Unity editor;
[0058] 2. Create an empty UI canvas (Canvas) as the root canvas;
[0059] 3. Create a top-level parent UI on the root canvas and name it group to store sorting elements and sorting element parent nodes;
[0060] 4. Add the ImgPieDragManager script to the group node;
[0061] 5. Add the ImgParent script to the parent node of the sorting element and set the RealId attribute, which is the real sequence ID (preset the correct sequence ID);
[0062] 6. Add the script ImageCollision to each sorting element, set the RealId attribute, which is the real sequence ID; then add components BoxCollider, Rigidbody, and CanvasGroup;
[0063] 7. Add the first component to disrupt the order, and set this component to the btn attribute of the ImgPieDragManager script;
[0064] 8. Add a second component to check the correctness of the sorting at the end, and set this component to the btnCheck property of the ImgPieDragManager script;
[0065] 9. Add an additional temporary parent node at the end of the Group to put the elements into it when dragging so that the sorting elements can be displayed on the top layer.
[0066] Based on the above settings, you can start collision detection and sorting detection of the elements to be sorted. The following is a specific operation step, including the following steps:
[0067] 1. The element to be sorted starts to be dragged, set to be draggable, open the collision box to allow collision, save the original parent node, replace the new parent node, and make the element transparent by 60%;
[0068] 2. Update the position of the elements to be sorted during the dragging process;
[0069] 3. Detect whether it collides with other draggable elements;
[0070] 4. After the dragging is finished, the parent nodes of the two elements are exchanged according to whether there are other collision elements. The colliding elements are added to their respective exchanged parent nodes, and the element positions are reset to complete the position display exchange function; if no collision occurs with other elements, the dragged element is returned to the original parent node and the element position is reset. When the dragging is finished, the transparency of the element is restored to 100%;
[0071] 5. Randomly shuffle the positions of the elements to be sorted and redistribute them to the parent node;
[0072] 6. Traverse the sorting elements and compare the real sequence ID of the sorting element with the real sequence ID of its corresponding parent node to determine whether it is dragged in correctly to complete the sorting detection.
[0073] The method in this embodiment has the following effects and advantages:
[0074] A UI interaction function compatible with multiple terminals is realized: Traditionally, functions such as sorting, dragging, and collision can only be realized by doing different development for different terminals. For example, PC development uses the PC's collision detection and dragging methods, and VR development uses the VR's collision detection and dragging methods. This makes it impossible to develop for multiple terminals at one time. The Rigidbody component used in this application is combined with the BoxCollider component to handle the collision problem, which solves the problem that collision can be achieved on the PC, VR, and AR sides. Combined with the XR virtual handle interaction, the problem of replacing the mouse operation in VR and AR is solved. Therefore, without adding XR, it can be applicable to PC desktop and mobile phones. Adding XR assistance can be applicable to VR and AR helmets, solving the problem of multiple terminals.
[0075] Therefore, this application achieves cross-device compatibility: it is developed based on Unity UGUI and XR Interaction Toolkit, and is cross-device compatible with VR and AR devices produced by different manufacturers, making the platform more scalable and efficient;
[0076] Reduced workload: Since the approach provides a highly reusable framework, developers no longer need to repeatedly design and write code. This reduces workload, reduces the possibility of errors, and saves time;
[0077] Improve development efficiency: By using this method, developers can develop features more quickly, thereby improving development efficiency. This means that new applications can be launched faster to meet user needs;
[0078] Cross-platform compatibility: This method is based on Unity UGUI, a cross-platform user interface tool, which means that functions created using this method can easily run on different operating systems and devices without additional adaptation work, thus improving the portability of the application;
[0079] Reduced maintenance costs: Since this approach provides a standardized way of creating, it reduces the use of custom code and specific solutions in the project; it reduces maintenance costs because when updating or fixing problems, only one place needs to be modified instead of multiple parts.
[0080] Provide a consistent user experience: This approach encourages the use of standardized interface elements and interaction patterns, thereby providing a consistent user experience for users. This helps reduce user confusion and increases user satisfaction with the app.
[0081] In summary, the advantages of this method are that it simplifies the development process of implementing UI collision detection and judgment sorting functions on multiple terminals, reduces workload, improves development efficiency, and makes the created interface easily run on multiple platforms and devices by utilizing the cross-platform capabilities of Unity UGUI and the cross-device capabilities of XRInteraction Toolkit. These advantages help developers develop faster and more efficiently, thereby providing a better user experience and reducing development costs.
[0082] Therefore, the method proposed in this application for quickly implementing UI element collision detection and sorting judgment based on Unity UGUI and XR Interaction Toolkit provides new ideas and solutions for the development of multi-terminal interactive applications. The implementation of this method can greatly improve the user experience and has broad application prospects.
[0083] In this embodiment, a computer device is provided, such as Figure 2 As shown, it includes a memory 201, a processor 202, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, any of the above-mentioned multi-terminal compatible UI collision and sorting detection methods is implemented.
[0084] Specifically, the computer device may be a computer terminal, a server or a similar computing device.
[0085] In this embodiment, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program for executing any of the above-mentioned multi-terminal compatible UI collision and sorting detection methods.
[0086] Specifically, computer-readable storage media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer-readable storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable storage media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0087] Based on the same inventive concept, an embodiment of the present invention also provides a multi-terminal compatible UI collision and sorting detection device, as described in the following embodiments. Since the principle of solving the problem by the multi-terminal compatible UI collision and sorting detection device is similar to that of the multi-terminal compatible UI collision and sorting detection method, the implementation of the multi-terminal compatible UI collision and sorting detection device can refer to the implementation of the multi-terminal compatible UI collision and sorting detection method, and the repeated parts will not be repeated. As used below, the term "unit" or "module" can be a combination of software and / or hardware that implements predetermined functions. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.
[0088] Figure 3 is a structural block diagram of a multi-terminal compatible UI collision and sorting detection device according to an embodiment of the present invention, such as Figure 3 As shown, it includes: a toolkit acquisition module 301, a root canvas creation module 302, a first script adding module 303, a second script adding module 304, a collision detection module 305, an element shuffling module 306 and a sorting detection module 307. The structure is described below.
[0089] A toolkit acquisition module 301 is used to acquire a toolkit for a cross-platform interactive application based on a Unity editor;
[0090] A root canvas creation module 302 is used to create a root canvas for displaying UGUI based on the toolkit, and to create a top-level parent UI for storing the elements to be sorted and the parent nodes of the elements to be sorted on the root canvas;
[0091] A first script adding module 303 is used to add an ImgPieDragManager script to the top-level parent UI, wherein the ImgPieDragManager script is used to process the random shuffling of the positions of the elements to be sorted, the relationship mapping between the elements to be sorted and the parent nodes, and the sorting detection of the elements to be sorted;
[0092] The second script adding module 304 adds a parent node of a preset correct order to each element to be sorted and then adds it to the top-level parent UI, and adds a script for collision detection to each element to be sorted;
[0093] A collision detection module 305, used for dragging and collision detection of the elements to be sorted based on the script for collision detection;
[0094] An element shuffling module 306 is used to randomly shuffle the elements to be sorted after collision detection based on the ImgPieDragManager script;
[0095] The sorting detection module 307 is used to compare the shuffled IDs of the elements to be sorted with the preset correct order of the parent nodes based on the ImgPieDragManager script to perform sorting detection on the elements to be sorted.
[0096] In one embodiment, the collision detection module 305 is further used to:
[0097] The scripts for collision detection include ImageCollision scripts, BoxCollider scripts, Rigidbody scripts and CanvasGroup scripts. The ImageCollision script is used to process collision, dragging and position exchange of elements to be sorted, the BoxCollider script is used to define the collision volume and position of elements to be sorted, the Rigidbody script is used to trigger collision events, and the CanvasGroup script is used to control the transparency of elements to be sorted.
[0098] In one embodiment, the apparatus further comprises:
[0099] The temporary parent node adding module is used to add a temporary parent node to each of the elements to be sorted, so that the elements to be sorted are displayed on the top layer when being dragged through the temporary parent node.
[0100] In one embodiment, the apparatus further comprises:
[0101] The sorting content adding module is used to add sorting content to each of the elements to be sorted, and the sorting content includes text, pictures and videos.
[0102] In one embodiment, the apparatus further comprises:
[0103] A first component setting module, used to set a first component for the btn attribute of the ImgPieDragManager script, wherein the first component is used to randomly shuffle the elements to be sorted after being clicked;
[0104] The second component setting module is used to set the second component for the btnCheck attribute of the ImgPieDragManager script, and the second component is used to perform sorting detection on the elements to be sorted after being clicked.
[0105] In one embodiment, the root canvas creation module 302 is further used to:
[0106] In the Unity editor, based on the toolkit, a root canvas is created for displaying the UGUI, and the mode of the root canvas is changed to the world mode;
[0107] Add an XR tracking device graphics ray caster built-in script to the root canvas, and use the script to make the elements to be sorted interactive by ray clicking.
[0108] In one embodiment, the toolkit acquisition module 301 is further used to:
[0109] The toolkit for cross-platform interactive applications is the XR Interaction Toolkit.
[0110] The embodiments of the present invention achieve the following technical effects: the method of the present application is based on a toolkit for cross-platform interactive applications built into the Unity editor, and verifies whether the sorting is correct by comparing the parent node IDs of the preset correct order with the IDs of the elements to be sorted. At the same time, the inheritance method of the Unity built-in script is used to write the required drag and collision logic to realize the dragging, transposition and collision of elements, so that Unity developers do not need to spend energy and time to repeatedly write collision detection and sorting detection functions, and can also save developers from writing multiple versions of functions, which can help developers to achieve multi-end availability through one-time writing, improve developer efficiency, simplify production complexity, and thus save development costs.
[0111] Obviously, those skilled in the art should understand that the modules or steps of the above-mentioned embodiments of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the embodiments of the present invention are not limited to any specific combination of hardware and software.
[0112] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A multi-terminal compatible UI collision and sorting detection method, characterized in that: include: Get a toolkit for cross-platform interactive applications based on the Unity Editor; A root canvas for displaying the UGUI is created based on the toolkit, and a top-level parent UI for storing the elements to be sorted and the parent nodes of the elements to be sorted is created on the root canvas; Add an ImgPieDragManager script to the top-level parent UI, where the ImgPieDragManager script is used to handle the random shuffling of the positions of the elements to be sorted, the relationship mapping between the elements to be sorted and the parent nodes, and the sorting detection of the elements to be sorted; After adding a parent node with a preset correct order to each element to be sorted, add it to the top-level parent UI, and add a script for collision detection to each element to be sorted. The script for collision detection includes ImageCollision script, BoxCollider script, Rigidbody script and CanvasGroup script. The ImageCollision script is used to process the collision, dragging and position exchange of the elements to be sorted, the BoxCollider script is used to define the collision volume and position of the elements to be sorted, the Rigidbody script is used to trigger collision events, and the CanvasGroup script is used to control the transparency of the elements to be sorted; Drag and drop the sorting elements and perform collision detection based on the script for collision detection; Based on the ImgPieDragManager script, the elements to be sorted after collision detection are randomly shuffled; Based on the ImgPieDragManager script, the shuffled IDs of the elements to be sorted are compared with the preset correct order of the parent nodes to perform sorting detection on the elements to be sorted.
2. The multi-terminal compatible UI collision and sorting detection method according to claim 1, characterized in that: The method further comprises: A temporary parent node is added to each of the elements to be sorted, and the temporary parent node enables the elements to be sorted to be displayed on the top layer when being dragged.
3. The multi-terminal compatible UI collision and sorting detection method as claimed in claim 1, characterized in that: Before the step of dragging and collision detection on the elements to be sorted based on the script for collision detection, the method further includes: Sorting content is added to each of the elements to be sorted, and the sorting content includes text, pictures and videos.
4. The multi-terminal compatible UI collision and sorting detection method as claimed in claim 1, characterized in that: The method further comprises: The btn attribute of the ImgPieDragManager script is set with a first component, where the first component is used to randomly shuffle the elements to be sorted after being clicked; The btnCheck property of the ImgPieDragManager script is set with a second component, where the second component is used to perform sorting detection on the elements to be sorted after being clicked.
5. The multi-terminal compatible UI collision and sorting detection method as claimed in claim 1, characterized in that: The root canvas for displaying UGUI is created based on the toolkit, including: In the Unity editor, based on the toolkit, a root canvas is created for displaying the UGUI, and the mode of the root canvas is changed to the world mode; Add an XR tracking device graphics ray caster built-in script to the root canvas, and use the script to make the elements to be sorted interactive by ray clicking.
6. The multi-terminal compatible UI collision and sorting detection method according to any one of claims 1 to 5, characterized in that: The toolkit for cross-platform interactive applications is the XR Interaction Toolkit.
7. A multi-terminal compatible UI collision and sorting detection device, characterized in that: include: Toolkit acquisition module, used to obtain toolkits for cross-platform interactive applications based on the Unity editor; A root canvas creation module, used to create a root canvas for displaying UGUI based on the toolkit, and to create a top-level parent UI for storing the elements to be sorted and the parent nodes of the elements to be sorted on the root canvas; A first script adding module is used to add an ImgPieDragManager script to the top-level parent UI, wherein the ImgPieDragManager script is used to process the random shuffling of the positions of the elements to be sorted, the relationship mapping between the elements to be sorted and the parent nodes, and the sorting detection of the elements to be sorted; The second script adding module adds a parent node of a preset correct order to each element to be sorted and then adds it to the top-level parent UI, and adds a script for collision detection to each element to be sorted. The script for collision detection includes an ImageCollision script, a BoxCollider script, a Rigidbody script and a CanvasGroup script. The ImageCollision script is used to process the collision, dragging and position exchange of the elements to be sorted, the BoxCollider script is used to define the collision volume and position of the elements to be sorted, the Rigidbody script is used to trigger a collision event, and the CanvasGroup script is used to control the transparency of the elements to be sorted; A collision detection module, used for dragging and collision detection of the elements to be sorted based on the script for collision detection; An element shuffling module, used for randomly shuffling the elements to be sorted after collision detection based on the ImgPieDragManager script; The sorting detection module is used to compare the shuffled IDs of the elements to be sorted with the preset correct order of the parent nodes based on the ImgPieDragManager script to perform sorting detection on the elements to be sorted.
8. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the multi-terminal compatible UI collision and sorting detection method according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program for executing the multi-terminal compatible UI collision and sorting detection method according to any one of claims 1 to 6.
