A supplement to the article "Share your little map written in C + +"

Source: Internet
Author: User
Tags addchild

After writing the previous article, I found a question:

That is, the plugin cannot be previewed in real time.

After learning slate, I found a way to:

Overriding the Synchronizeproperties function

The header file is added:

#if With_editor    ufunction ()    virtualvoidoverride; #endif

Because it only needs to be run in the editor, add # if With_editor

CPP file, add the following:

#ifWith_editorvoiduminimap::synchronizeproperties () {super::synchronizeproperties (); Widgetsize= -; Maptexturesize= +; //Building ComponentsMainmap = newobject<uimage> ( This, TEXT ("Mainmap")); Playercursor= Newobject<uimage> ( This, TEXT ("Playercursor")); Frame= Newobject<uimage> ( This, TEXT ("Frame")); //adding components to widget containersRootpanel = cast<ucanvaspanel> (widgettree->rootwidget); if(rootpanel) {Rootpanel-AddChild (MAINMAP); Rootpanel-AddChild (playercursor); Rootpanel-AddChild (Frame); } umaterialinstance*mainmapmaterialinstance = loadobject<umaterialinstance> (NULL, TEXT ("/game/ui/images/minimapmaterial_instance"), NULL, load_none, NULL); if(mainmapmaterialinstance) {mainmapmaterial=ukismetmateriallibrary::createdynamicmaterialinstance (Getworld (), mainmapmaterialinstance); if(mainmapmaterial->parent->getmaterial ()->materialdomain = =md_ui) {Uwidgetlayoutlibrary::slotascanvasslot (Mainmap)-SetSize (fvector2d (Widgetsize, widgetsize)); Mainmap-setbrushfrommaterial (mainmapmaterial); Mainmapmaterial->setscalarparametervalue (FName (TEXT ("Minimapscaleratio")), (float) Widgetsize/maptexturesize); }} utexture2d* Playercursortexture = loadobject<utexture2d> (NULL, TEXT ("/game/ui/images/playercursor"), NULL, load_none, NULL); if(playercursortexture) {uwidgetlayoutlibrary::slotascanvasslot (playercursor)->setsize (Fvector2d (Playercursortexture->getsizex (), playercursortexture->Getsizey ())); Playercursorsize= playercursortexture->Getsizex (); Uwidgetlayoutlibrary::slotascanvasslot (playercursor)->setposition (fvector2d (-playercursorsize/2+ Widgetsize/2,-playercursorsize/2+ Widgetsize/2)); Playercursor-setbrushfromtexture (playercursortexture); }    if(Setimageburshfrommaterial (TEXT ("/game/ui/images/framematerial"), Frame, fvector2d (Widgetsize, widgetsize))) {Uwidgetlayoutlibrary::slotascanvasslot (frame)-SetSize (fvector2d (Widgetsize, widgetsize)); }    //you can consider adding other buttons and borders later}#endif

However, there is a small problem, in the new blueprint (Inherit this class blueprint) Mad point, the engine will be directly collapsed, there is no solution, the engine is Slate, forum and Answerhub also have no relevant information, but this problem does not affect the use, so the tutorial ends.

A supplement to the article "Share your little map written in C + +"

Related Article

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.