What you’re encountering seems to be related to how Unreal Engine handles property changes in blueprints, particularly with Common UI and the Style
attribute. This behavior might not necessarily be a bug, but rather how Unreal caches or initializes properties in certain cases. Here’s a breakdown of what might be happening and how to address it:
Likely Causes:
-
Caching Issue:
- Unreal Engine may cache certain properties, like the
Style
attribute, at blueprint compilation or engine startup. Changing theStyle
in theClass Defaults
may not trigger a proper update until the engine is restarted.
- Unreal Engine may cache certain properties, like the
-
Property Initialization:
- Some properties, especially those tied to class defaults, might not reinitialize dynamically at runtime when changed. This could explain why the
Get Style
node still references the originalButtonStyle1
until the engine is rebooted.
- Some properties, especially those tied to class defaults, might not reinitialize dynamically at runtime when changed. This could explain why the
-
Blueprint Editor Not Refreshing:
- The Blueprint Editor occasionally does not fully propagate changes to the runtime instance. This is common when changing class defaults rather than runtime variables.
-
Common UI Framework Quirk:
- The Common UI framework has certain quirks when working with
Style
attributes and class defaults. The behavior you’re seeing could stem from how Common UI widgets are constructed and initialized.
- The Common UI framework has certain quirks when working with
Possible Solutions:
-
Force Blueprint Refresh:
- After changing the
Style
attribute, try recompiling your blueprint by clicking Compile in the toolbar. Then save the blueprint. Sometimes this forces Unreal to recognize changes without restarting the engine.
- After changing the
-
Use Runtime Initialization:
- Instead of relying solely on the
Class Defaults
for setting theStyle
, try setting it dynamically during theBegin Play
orPre Construct
events in yourButton_Simple
blueprint. For example:
This ensures the style is explicitly set at runtime, avoiding potential caching issues.On Begin Play: Set Style -> "ButtonStyle2"
- Instead of relying solely on the
-
Debugging the Style Property:
- Add debug output to verify whether the
Style
is correctly set when you change it. For example, log or print theGet Style
output after the blueprint is recompiled to confirm the property change.
- Add debug output to verify whether the
-
Force Widget Rebuild:
- If the widget or button isn’t refreshing after the
Style
change, you can try calling a function likeInvalidate Layout and Volatility
on the widget to force it to rebuild.
- If the widget or button isn’t refreshing after the
-
Test in a Clean Project:
- Create a minimal test project to verify if the issue persists with the same steps. This will help you determine if the problem is specific to your project setup or a Common UI issue.
-
Check for Common UI Updates:
- If you’re using an older version of Unreal, ensure you’re on the latest version. Common UI has been updated several times, and newer versions might address this behavior.
Workaround:
If the issue persists despite these steps, you can implement a temporary workaround:
- Always apply the
Style
dynamically during the widget’s initialization (e.g.,Pre Construct
orBegin Play
). - Use variables to store your desired
Style
and apply it programmatically, bypassing the reliance onClass Defaults
.
Is it a bug?
It could be a minor bug or a limitation in how the Common UI framework initializes its properties. If none of the solutions above resolve the issue, consider reporting it to Epic Games via their Unreal Engine Bug Submission Form with the detailed steps you’ve provided.
Let me know if you need help implementing any of these solutions!