JamieG
04-05-2010, 09:17 AM
I thought I'd share this brief tutorial on UIScenes that I had put together for UT3. It demonstrates one method of working with UIScenes that involves unrealscript instead of kismet. I use this method for my UI and haven't encountered any problems with it yet.
Step One: start your UIScene class. It can be blank, just as long as it exists. Then compile.
class MyNewUIScene extends UTUIFrontend;
DefaultProperties
{
}
Step Two: Create your UIScene in the editor using your new UIScene Class. Add all your button, image, label widgets to the scene. Remember what you name each widget (eg. a button named 'but_CloseScene'), you'll need it later. Save your scene and quit the editor.
Step Three: Now to link your widgets to the code:
class MyNewUIScene extends UTUIFrontend;
//declare a variable for each widget you want linked to the code
var transient UIButton MyButton;
var transient UIImage MyImage;
//link the widgets to the variables when the scene is initialized
event PostInitialize()
{
Super.PostInitialize();
//find the widget in the scene and cast it to the appropriate type, then assign to the transient variable.
MyButton = UIButton( FindChild('but_CloseScene', true) );
MyImage = UIimage( FindChild('img_Background', true) );
//Assign a delegate function for the button
MyButton.OnClicked=OnCloseScene;
}
function bool OnCloseScene(UIScreenObject InButton, int InPlayerIndex)
{
CloseScene(self);
return true;
}
DefaultProperties
{
}
There you go, now your widgets are linked to the code at runtime so there will be no catastrophic errors if you change either the code or UIScene. Hope this helps!
Step One: start your UIScene class. It can be blank, just as long as it exists. Then compile.
class MyNewUIScene extends UTUIFrontend;
DefaultProperties
{
}
Step Two: Create your UIScene in the editor using your new UIScene Class. Add all your button, image, label widgets to the scene. Remember what you name each widget (eg. a button named 'but_CloseScene'), you'll need it later. Save your scene and quit the editor.
Step Three: Now to link your widgets to the code:
class MyNewUIScene extends UTUIFrontend;
//declare a variable for each widget you want linked to the code
var transient UIButton MyButton;
var transient UIImage MyImage;
//link the widgets to the variables when the scene is initialized
event PostInitialize()
{
Super.PostInitialize();
//find the widget in the scene and cast it to the appropriate type, then assign to the transient variable.
MyButton = UIButton( FindChild('but_CloseScene', true) );
MyImage = UIimage( FindChild('img_Background', true) );
//Assign a delegate function for the button
MyButton.OnClicked=OnCloseScene;
}
function bool OnCloseScene(UIScreenObject InButton, int InPlayerIndex)
{
CloseScene(self);
return true;
}
DefaultProperties
{
}
There you go, now your widgets are linked to the code at runtime so there will be no catastrophic errors if you change either the code or UIScene. Hope this helps!