Unity Ugui Graphics Mixed Source--optimized version

Source: Internet
Author: User
Tags mixed versions
Preface

Because there are many students in the use of graphics and text mixed in the time, there are a lot of performance problems, resulting in frame rate is not stable, even very low. Bloggers are very sorry about this, at that time only by interest, in a function of constantly superimposed, almost no consideration of performance optimization. This time for a few days of free, on the graphics and text mixed to do a finishing and optimization. In fact, this blog is relatively late, on the GitHub bloggers are updated code in a timely manner, interested students welcome attention. However, bloggers on the picture mixed with no actual use of the opportunity, there may be some places still have to consider the imperfect place, Bo Master will try to optimize.forced optimizationDynamic expression of the number of frames can be less, I test here because is the use of network resources, each dynamic expression has eight pictures, in the actual project recommended two should be enough. You can use static expressions to give up dynamic expressions. Because the dynamic expression is updated in the update of the image of the UV to do the expression switch, if the use of static expression will save a lot of cyclic calculation. The expression can be less, no matter in each text, or in the entire chat box. Depending on the project's needs, you can limit the number of emoticons in text, or use the object pool to dynamically delete or remove objects, but I don't have to encapsulate the object pool here, and I need to customize it. You can use a single atlas without using multi-atlas for the same reason. If you do not use the expression, it is certainly better performance, this is a nonsense. The mandatory optimization here is from the most intuitive to save performance, simple and rough, and good results.configuration file Substitution character resolutionThe previous version is the expression name, size, scale, and so on a series of parameters, put in text inside through the Setverticesdirty function at the beginning of the parse obtained. These parameters are now written in Spriteasset, and can be edited in the editor. Then only need to read the Spriteasset file at the beginning, know the current information, such as the name of the expression, which sprite in each expression, the size of each sprite, UV and other related information. Example screenshot:
Here also added a tag of the variable, in the pre-configuration, is to put a dynamic expression of all the sprites are selected under the same label
Simplifying Regular ExpressionsConversion comparison: <quad name=test size=24 wdith=1/>->[#test]Multi-Atlas SupportSupport multi-atlas: [Atlas id# expression name], Atlas ID corresponding to Spriteassets ID, expression name corresponding to the Spriteassets label, ID 0 o'clock, can omit to write
Support HyperlinksSupport hyperlinks, when the Atlas ID is 1, the default is a hyperlink, followed by the link name, example [ -1# hyperlink name], and in Inlinetext there is a Onhrefclick event can listen to click
avoid repeated drawing of spritesConverting previous versions of the world coordinate information to local coordinates, as long as the position information of the relative parent object is not changed, can avoid repeating drawing. In previous versions, dragging scroll view for this reason caused a lot of redundant computations, resulting in very low frame rates.

Add the Spritegraphic model to the contrast package, with the label and position information as the contrast parameter, if the same, no more picture drawing

#region Model data Information

Private class Meshinfo
{public
    string[] _tag;
    Public vector3[] _vertices;
    Public vector2[] _UV;
    Public int[] _triangles;

    Compare data as Public
    bool Equals (meshinfo _value)
    {
        if (_tag.length!= _value._tag.length| | _ vertices.length!= _value._vertices.length)
            return false;
        for (int i = 0; i < _tag.length; i++)
            if (_tag[i]! = _value._tag[i])
                return false;
        for (int i = 0; i < _vertices.length; i++)
            if (_vertices[i]! = _value._vertices[i])
                return false;
        return true;
    }
}

#endregion
the overriding text occupies a wide height

Because the text will add some other strings to text according to the regular, so the default PreferredWidth and PreferredHeight is no longer accurate, here according to the actual text content recalculation, convenient to do chat bubbles and other functions of the text to occupy the width of the high acquisition Add Level Management

Add a Inlinemanager script that manages all the spritegraphic and Inlinetext in the sub-object and ensures the correct connection and hierarchy of the two.
It is also possible to create multiple Inlinemanager to guarantee the non-interference between each other. New Quick Create

You can create a default UI preset directly by clicking Gameobject/ui/textinline, just as you would create a different UI. Source Link

Github:https://github.com/coding2233/textinlinesprite problem left in the editor, will cause the system abnormal lag, in another Win7 system has no impact, the affected system is WIN10 ; For the preview of the expression in the editing mode to draw a logical collation, for the operation of the logical process of the collation; Occasionally there may be some abnormal performance;

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.