GrimyBunyip Posted March 7, 2016 Share Posted March 7, 2016 I'm trying to figure out how to draw a simple rectangle. I started by trying to make a UIBGBox: GrimyBox1 = Spawn(class'UIBGBox', self); GrimyBox1.InitBG('BGBoxSimple').SetBGColor("red"); GrimyBox1.SetHighlighed(true); GrimyBox1.AnchorCenter(); GrimyBox1.SetPosition(-250,400); GrimyBox1.SetSize(5 * (GrimyHitChance - GrimyCritChance),20); GrimyBox2 = Spawn(class'UIBGBox', self); GrimyBox2.InitBG('BGBoxSimple').SetBGColor("yellow"); GrimyBox2.SetHighlighed(true); GrimyBox2.AnchorCenter(); GrimyBox2.SetPosition(-250 + 5 * (GrimyHitChance - GrimyCritChance - GrimyDodgeChance),400); GrimyBox2.SetSize(5 * GrimyCritChance,20);The above code will draw box1, but will not draw box2.If I comment out the code for box1, box2 will appear. I don't understand why these two are mutually exclusive. I tried using UIPanel instead of UIBGBox, but nothing appears. has anyone else experimented with UI elements yet? Link to comment Share on other sites More sharing options...
MachDelta Posted March 7, 2016 Share Posted March 7, 2016 My hunch is that it's because both boxes are given the same name - "BGBoxSimple". Try either naming them separately, or not at all (the name is an optional variable, the default is to have the engine generate a unique name). Try that and see what happens. Link to comment Share on other sites More sharing options...
traenol Posted March 7, 2016 Share Posted March 7, 2016 MachDelta is correct simulated function UIBGBox InitBG(optional name InitName, optional float InitX, optional float InitY, optional float InitWidth, optional float InitHeight, optional EUIState InitColorState = eUIState_Faded) { ... } While the name IS optional, meaning the function does not require it to create an object, having two objects with the same name will not work, because this is how a UIPanel is accessed. Most likely the code throws out panel two because the initialization fails to create a new object(one already exists). Changing the name 'should' resolve your issue, and would be good practice, as you should never have two objects named the same. Link to comment Share on other sites More sharing options...
Recommended Posts