top of page
Search

Etheri Dev Log #9: Creating an attribute menu and encountering the most annoying bug I've had so far!

Work in progress Attribute Menu
Work in progress Attribute Menu

When creating a big chunk of UI like this I've found that it'll make your life a lot easier if you break it down into separate widget blueprints and then put those blueprints into one main widget blueprint. You might surprise yourself later on in development and find more uses for those smaller separate widget blueprints.

 WBP Text value is the parent class of wbp text value button
WBP Text value is the parent class of wbp text value button

A nice way to look at it, is that whatever information on the UI that is going to be filled out dynamically when you press play should be its own separate widget that way you prevent having a lot of code in one blueprint. In the same way you have different classes for different objects in C++.


Just like all other elements of my UI the attribute menu follows the model view controller design pattern, so the attribute menu has its own widget controller which is responsible for broadcasting the attribute values to the widget blueprints.


The model part of this pattern is in form of a new class I've encountered which is Data Assets. How it works is explained down below.

A bug that had me stumped for a while was that the values of the attributes in the attribute menu were displayed as 0 when if I use the console command show debug ability system it displayed the attributes as having the correct values. So instantly I knew the problem was that the information of the attributes wasn't being passed into the UI widgets.


The problem was I knew that the setup for this feature was correct because the names of all the attributes were being filled out correctly and I could debug to see that the description of the attributes were being parsed through, as well as the attribute tags themselves. It was just the float variable where things were going wrong.


Eventually after doing some breakpoint debugging on the moment my attribute information was being broadcasted I noticed that my attribute set had two separate references at two different stages of my game. At some point I must have renamed "Attribute Set" to be "AttributeSet".

I found this piece of documentation which explains the reason behind why my attribute set was causing the bug. https://dev.epicgames.com/documentation/en-us/unreal-engine/core-redirects-in-unreal-engine.

To summarise when an object be it a class, function or variable gets renamed, if a lot of things are referencing that object especially on the blueprint side of things. Just recompiling will cause Unreal to no longer recognise the assets that are referencing that renamed object.


To get around this you need to use CoreRedirects in your DefaultEngine.ini file these will remap your renamed functions classes, structs and enums to what they were previously called.


So a word of warning don't fiddle with important class' names. If you are unhappy with the naming conventions of some parts of your code midway through development use core redirects.

 
 
 

Commentaires


bottom of page