Unreal3 Object Management Module Analysis two

Source: Internet
Author: User

The previous article mainly recorded the creation of Uclass, now summarizes the creation of uobject, can be understood from a few different angles.

From the way, you can divide the classes according to the Uobject constructor:

    // constructors.     uobject ();     Const uobject& SRC);    Uobject (Enativeconstructor, uclassconstconst tchar* Inpackagename, Eobjectflags inflags);     Const Const tchar* Inpackagename, Eobjectflags inflags);

2 is the copy constructor is not related to the initial creation, 3 basic has not seen (from the comment should be dynamic link is useful, and 4 effect similar), the most important is 1 and 42 kinds.

4 is the base class constructor called by Uclass this special subclass at construction time, where Inname is the class name.

1 is the default constructor, usually in Uobject::staticconstructobject (), that is, the dynamic creation of a class of objects when called, used to make an empty object, can say that the other uobject subclasses, the basic is created in this way.

For 1, there are several calling contexts:

The first is to come out directly in new tclass, such as :

New (Inouter, FName (*inname, Fname_add, TRUE), rf_public) Upackage;

The second is created dynamically with Uobject::staticconstructobject, which first staticallocateobject allocates memory and then initializes it by Internalconstructor on the object address returned by the former:

//Allocate the object.uobject* Result =Staticallocateobject (Inclass, Inouter, Inname, Inflags, Intemplate, Error, NULL, Subobjectroot, instancegraph); if(Result) {{Tguardvalue<UBOOL> Isaffectingcdo (Gisaffectingclassdefaultobject, (inflags&rf_classdefaultobject)! =0); //Call the base Uobject class constructor if the class was misaligned (i.e. a native class that's currently being recom Piled)            if( ! Inclass->ismisaligned ()) {                (*inclass->classconstructor)            (Result); }            Else            {                (*uobject::staticclass ()classconstructor)            (Result); }        }

Where Inclass->classconstructor is a property in Uclass, it points to the Internalconstructor function in the class it represents, and there is a function in each class that is mentioned in the previous article declare_ Defined in the Class macro:

Static void void* x)         New((einternal*) x) Tclass; }

For example, when you want to create a class object, you usually get its uclass first, and then call Spawnactor to create it. In the game logic core class Gameinfo:

Unreal3 Object Management Module Analysis two

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.