Summary
Material Block not setting material correctly when material is referenced inside of a class
Please select what you are reporting on:
Creative
What Type of Bug are you experiencing?
Verse
Steps to Reproduce
#######################################################################################################################
material_ui_test := class:
var MainOverlaySlot : overlay = overlay{}
SpinIconMaterial : MaterialBlockTest.M_UI_MB_IconTest_Inst_Exp_material = MaterialBlockTest.M_UI_MB_IconTest_Inst_Exp_material{}
MaterialBlockToUse : material_block = material_block{DefaultImage:=MaterialBlockTest.M_UI_MB_IconTest_Inst_Exp, DefaultDesiredSize:=vector2{X:=1024.0,Y:=1024.0}}
AddUI(Agent : agent):void=
if:
Player := player[Agent]
PlayerUI := GetPlayerUI[Player]
then:
set MainOverlaySlot = CreateMainOverlay()
PlayerUI.AddWidget(MainOverlaySlot, player_ui_slot {InputMode := ui_input_mode.None})
SetImageInside():void=
MaterialBlockToUse.SetImage(SpinIconMaterial)
CreateMainOverlay():overlay=
MainOverlay : overlay = overlay{
Slots := array:
overlay_slot:
Padding := margin{Left:= 40.0, Top:= 100.0, Right:=0.0, Bottom := 0.0}
HorizontalAlignment:=horizontal_alignment.Center
VerticalAlignment:=vertical_alignment.Center
Widget:=MaterialBlockToUse
}
####################################################################################################################
material_block_test_device := class(creative_device):
var MainOverlaySlot : overlay = overlay{}
SpinIconMaterial : MaterialBlockTest.M_UI_MB_IconTest_Inst_Exp_material = MaterialBlockTest.M_UI_MB_IconTest_Inst_Exp_material{}
MaterialBlockToUse : material_block = material_block{DefaultImage:=MaterialBlockTest.M_UI_MB_IconTest_Inst_Exp, DefaultDesiredSize:=vector2{X:=1024.0,Y:=1024.0}}
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
AllPlayers : []player = GetPlayspace().GetPlayers()
for(Player : AllPlayers):
PlayerUI := material_ui_test{}
PlayerUI.AddUI(Player)
#PlayerUI.MaterialBlockToUse.SetImage(PlayerUI.SpinIconMaterial) #Not Working - Method 1
#PlayerUI.SetImageInside() #Not Working - Method 2
PlayerUI.MaterialBlockToUse.SetImage(SpinIconMaterial) # Working
- Create Material In Class (use your own material)
- Create material_block (To be referenced later)
- After Creating UI. Call SetImage on previously created material block with the parameters of your material.
Code Stated Above - SetImage on a material block will result in a white sprite if you are trying to set a material that has been created inside of a class. If the material is created inside of a device, it will display correctly. This is an issue only when trying to use SetImage, having the material defaulted inside of a class will work, but as the materials aren’t referenced for later use, you will not be able to change their parameters (eg, can’t increment a progress bar).
Expected Result
The working method would be SetImage resulting in the material showing from inside of a class.
Observed Result
Materials are showing as white sprites.
Platform(s)
PC