PDA

View Full Version : [Tutorial]UIScenes & Unrealscript Together



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!

nsx_nawe
04-05-2010, 09:42 AM
thanks!, there should be more tutorial or snippets sharing common practical uses like this, even when small, it helps the community build up a lot, i mean, for newbies to udk as myself...

keep up the good work

abraham2
04-05-2010, 09:44 AM
Nice, very nice. it works fine .now I wonder how to use this for closing the game.could you help us on that.

JamieG
04-05-2010, 02:05 PM
Now I wonder how to use this for closing the game.could you help us on that.

You can call the Console Command "Quit":


function OnMenu_ExitGame()
{
ConsoleCommand("quit");
}

final function ConsoleCommand(string Cmd, optional bool bWriteToLog)
{
local LocalPlayer LP;
local UIInteraction UIController;

if ( Cmd != "" )
{
UIController = GetCurrentUIController();
LP = GetPlayerOwner(0);
if ( LP == None )
{
if ( UIController != None )
{
LP = UIController.GetLocalPlayer(0);
}
}

if ( LP != None )
{
if ( LP.Actor != None )
{
LP.Actor.ConsoleCommand(Cmd, bWriteToLog);
}
else if ( UIController != None && UIController.Outer.ViewportConsole != None )
{
UIController.Outer.ViewportConsole.ConsoleCommand( Cmd);
}
}
}
}



Ok, but what about UIScene animations? Do you have any ideas?

Check out the GameUISceneClient class and children, this is where they would be defined.

abraham2
04-05-2010, 03:43 PM
JamieG I've been really behind in my project just because the basic interface that i need .You are one of the best,Thanks.

anomandarius
04-05-2010, 10:14 PM
It's always wild how seeing it put together in a simple form can make it click some times.

I'll likely have a few specific questions after study but I'm reading the code with new eyes thanks to you.

OmegaMan
04-14-2011, 01:03 PM
Ok, let say i have created my the class "MyNewUIScene", how do I tell Unreal Editor to use the type "MyNewUIScene" instead of UIScene as base class type ?

Thata is my main concern. I am not able to link this UIScene asset with his peoper class.

Do I need to specify it in any .ini file ?

John J
04-14-2011, 01:45 PM
Did you realize this was a year old thread?

What version of UDK are you using? The UIScene system was completely pulled out many months ago in favor of using Scaleform, so if you are on current builds then you should be looking at Scaleform or writing to the canvas directly for your UI needs.

OmegaMan
04-14-2011, 03:47 PM
Yes I know.

We are using UDK-04-2010. We are not able to load packages into newer versions and since the project has been started with that version, my boss does not want me to loose time on migrating our project.

So, I can not use scaleform and I am stuck to UIScene.

Blade[UG]
04-14-2011, 04:58 PM
I think when you create a new uiscene, it has a thing for determining which uiscene class to use as the template?

OmegaMan
04-14-2011, 06:03 PM
I guess it is probably around selecting MyNewUIScene class in Actor classes and then go to Content browser, select proper package and create the UIScene using the selected class.

But I can't figure out exactly how.

Amala
05-08-2012, 07:17 AM
Hai,
I want to create UI scenes to my Game, i used canvas and hud for creating ui scene i displayed images and text but i dont hav idea about how to display a button action. I want to create my UI by using Unreal script only can any one pls help me how to create a perfect UI scene for creating Buttons and perform another action, and give me some links for UI scene cretion through scripting

Pls pls help me on this..

Thanks for any help

MVGS
05-16-2012, 12:14 PM
UIScenes are not recommended, they are an overly complicated system and probably are not supported at all in new UDK releases.

Solid Snake
05-16-2012, 05:49 PM
UIScenes do not exist any more, and haven't existed for at least a year or so.

Scaleform is the recommended way to do UI now; but if you absolutely want to use Canvas than the best place to start is to really learn how Canvas works. Alternatively you can use the Kismet + Canvas UI creation toolkit that is floating around (Hourences).