Unity3d Novice Guide Development notes

Source: Internet
Author: User

Recently began to take the lead in the development of novice, record this piece of relevant experiencefirst, the client is unity, before taking over, the front of the students have initially completed the novice guidance framework, the framework is relatively simple, there are advantages and disadvantages, one by one points later

Our novice guide is made up of a strong guide, each strong guide has a series of steps, the framework of the implementation of the function is:
1. Organize a strong guide (task) required steps, and can move forward
step by step
2. Implement masks, masks, and highlight boot areas
The first function is relatively simple, you need to have a novice boot manager to manage each step, and then start the first step, only in each click of event Processing, notify the Novice boot manager, end the current step, start the next step
The second function is relatively troublesome, first of all the steps may have a highlight area, we need to do not change the original code based on the implementation of this highlight, first we add a guide camera, the camera's priority is the highest, he only radiation guide this layer of things , and the bottom of this layer, there is a black mask, at the beginning of the execution of the step, we only need to highlight the object, set as the object of the layer , can be highlighted, and the mask to add a boxcollider, to prevent the player from clicking the mask below the button. At the end of the novice boot step, set the boot area back to the original layer.

  1. <font size= "4" >//find the object and set its layer
  2. private void Setobjectlayer (int layer, BOOL Isstart)
  3. {
  4. if (highlightobj! = null)
  5. {
  6. if (Isstart)
  7. {
  8. Highlightobjlayer = Highlightobj.layer;
  9. }

  10. Commontools.setlayer (highlightobj, layer);
  11. }
  12. }</font>
Copy Code

Each strong boot is a prefab, which records each step of the boot area, in the running state, find the boot area, drag to the prefab script, and then the script to find the full path of the area, after dragging the boot area of each step, then save the prefab, So we can find the boot area to highlight based on the path.

The above Guide area drag is very suitable for planners to design Novice guide, and dynamically change the boot area is located in the layer to achieve highlighting and shielding other buttons, is also more ingenious, but here about the steps to complete the relevant logic, coupling is very large, we look at how this is the next step to achieve
predecessors left the demo, is in each step corresponding to the highlight area of the button click Callback, add a line of code to notify the Novice boot Manager step to complete , that is, in the implementation process, each need to click the boot area of the steps, need to add such a line of code, the workload is large , and maintainability is poor
In addition, when the interface jumps, also need special processing, because the need to wait for the new interface loading completed, and display in order to perform the next step, so the demo in the interface fully display, to notify the Novice boot manager , and each interface loading complete standard is not unified, Some need to wait for a special effect to play, it will show that if the corresponding logic is not very familiar with, this piece of place very easy to make a bug
"Improvements"The following improvements are made specifically for the above two issues so that they do not need to add additional code to the original code to notify the steps to complete
whenever there is a highlight of the boot area, are clickable, then there must be boxcollider, when I get this object to set the level, the way to find this guide area of the Boxcollider, generally only one, because the guidance of each step is clear, After finding this boxcollider, add a delegate for his click Delegate, which is the delegate to complete the step, and then, at the end of the step, remove the delegate, eliminating the need to force the next code to be added at each click event, but in the Click event, Incidentally execute our delegate (original event handling delegate + Novice boot Step end delegate), so that you do not need to add additional code, destroy the package, the overall process is also very clear
for the second problem, the key is because when the interface is not displayed completely, we can not get the corresponding highlight area, here using reverse thinking, I wait for you to notify me after loading, I take the initiative to scan you, when we start the step, if there is a boot area first scan boot area, enable a collaboration, Every 0.2 seconds to actively find the boot area, when the interface is fully displayed, you can get the boot area, and do not need to load the corresponding interface to complete, and then write additional code to notify the Novice boot module this sidethrough the above two improvements, completely solved the novice boot and the original code logic coupling, the novice boot related functions are all gathered in the Novice boot module to achieve
"Other improvements"one is to use the message mechanism to replace the singleton, the original novice boot manager is a single case, but when you complete the novice boot, it is no longer necessary, so use the message mechanism to promote the novice boot manager, when the novice boot is complete, the message will be sent as usual, but the processor is missing
dynamically created based on the message from the server, only when I need to complete the novice boot, to create the Novice boot manager, and initialize the novice boottext hints and click on the screen continue, there are n types of text hint style, we implement it as a prefab, and according to the table shows the specific style, content, and click on the screen after the processing
"and server-linked"in the Novice guide this piece, the server only makes simple judgment, as long as it is not obvious error, we choose to trust the front end, and do the data storage and release work
in the front of the game, we need to do the exception handling, as well as the forced boot process, when the strong boot begins, it is mandatory to the endOur game guide is such, such as to the mall to buy items such a guide, are normal step by step, when go to purchase the completion of the steps, that is, notify the server, completed the boot, then will encounter three kinds of anomalies, when we go half of the time when we cut off, when we buy completed, No time to notify the server when disconnected, when we notify the server disconnected, there are different processing
first, if the line is not purchased, the player will be forced to restart the boot after re-connection
second, after the purchase did not notify the line off, then force the boot, but start execution, do abnormal detection, such as detecting whether there is a task item, if it is to complete the task directly
third, after the Purchase notice drop line, then directly let the player complete the Novice guide
Disclaimer: This document is from the "Dog Planing Learning Network" community, is the Netizen self-published Unity3d study articles, if there is any content violated your relevant interests, please communicate with the official, we will deal with the real-time.

More Highlights:Www.gopedu.com

Unity3d Novice Guide Development notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.