bsisko Posted May 28, 2018 Share Posted May 28, 2018 Is there a way to use script to code UI elements?For example, I have a GUIImage on the MainMenu GUI.I want to use script that when a mouse click is resgistered on the control, it will execute the code to change images likeGUIImage.Picture = filename.BTW, I am not at my work computer, so the above references are not correct, but approximations of what I know about Torque. Quote Link to comment Share on other sites More sharing options...
dstanton Posted May 29, 2018 Share Posted May 29, 2018 Certain GUI elements are updated on an action event, (ammo in the FPS demo, etc) . If you take a look at these events, you'll get a better idea of how it all works. I know theres a onObjectSelected(%this, %obj) event method, not sure if the scope exists on all GUI elements or what, but after it would be called, the main GUI element is stored in the %this variable and you're able to dig into the object further. A lot of these events and object properties can be found in the Torque documentation, found on google, you just have to keep in mind the object you're referencing. Quote Link to comment Share on other sites More sharing options...
Duion Posted May 29, 2018 Share Posted May 29, 2018 Can't you update any GUI at any time through scripts? You just pick the name of the GUI, a value in it and set it to something in script, then it will update. Quote Link to comment Share on other sites More sharing options...
dstanton Posted May 29, 2018 Share Posted May 29, 2018 I'm going to add that I am not the sharpest programmer, and I might have to take back what I had commented earlier. onObjectSelected(%this, %obj) isn't a GUI function and should be ignored. Some of what I said should make a little more sense when you get to know the system more. Quote Link to comment Share on other sites More sharing options...
bsisko Posted March 5, 2019 Author Share Posted March 5, 2019 Duion,Can you be a little more specific about what yo mean about updateing the GUI Quote Link to comment Share on other sites More sharing options...
Duion Posted March 5, 2019 Share Posted March 5, 2019 For example I have a backgroundGui that I replace with random background images through script every time you enter the main menu:https://github.com/Duion/Uebergame/blob/master/scripts/client/init.cs#L216 Quote Link to comment Share on other sites More sharing options...
bsisko Posted April 12, 2019 Author Share Posted April 12, 2019 Okay here is what I have!I have an GUIBitmapCtrl and GUIButtonCtrl in my PlayGUI.In my files I have a function named DeSign in my Game.cs script fileIn the playGUI, I have the GUIBitmapCtrl properties set as: position = 34 39 extent = 549 640What I want to do is when I click on the GuiButtonCtrl button I want to shrink the GUIBitmapCtrl control to the lower right hand corner by setting the properties like this position = 500 400 extent = 100 200and make the GUIButtonCtrl disappear by setting its visible property to false. I have in the command property tab of the GUIButtonCtrl the name of the function DeSign. Quote Link to comment Share on other sites More sharing options...
irei1as Posted April 13, 2019 Share Posted April 13, 2019 (edited) First you need to give the pair of gui objects global names (there are other ways to do it but global names are the easiest).To set the name write it in its place in the gui editor.http://docs.garagegames.com/torque-3d/official/content/documentation/GUI%20Editor/Overview/Introduction.htmlYou can see the global name box in the picture. It says OptPostFxTo. Let's say you named them 'MyButton' and 'MyBitmap'.Inside the 'DeSign' function that is called when you click the button you add:MyBitmap.setPosition(500,400);MyBitmap.setExtent(100,200);MyButton.setVisible(false);Those functions are from gui in general as you can see inhttp://docs.garagegames.com/torque-3d/reference/classGuiControl.htmlNote the format GlobalName.methodName(params);If it doesn't work be sure to check the console for errors. Some name might be misspelled or a ; could be hanged somewhere. Check all the console for red messages.Edit: that documentation is a bit old but it works.For extra help you may want to check http://wiki.torque3d.org/main:documentation or look at some posts around in this forum. Edited April 15, 2019 by irei1as Quote Link to comment Share on other sites More sharing options...
bsisko Posted April 15, 2019 Author Share Posted April 15, 2019 Thanks irei1as,I'll give it a try tonight!! Quote Link to comment Share on other sites More sharing options...
bsisko Posted April 15, 2019 Author Share Posted April 15, 2019 I have the function in the game.cs file that is located in the server directory. It is exec'ed (or supposed to be exec'ed) by the main.cs file in the game folder (not the main.cs file in the example folder.) Nevertheless, the console reports that it cannot find the function. Quote Link to comment Share on other sites More sharing options...
bsisko Posted April 15, 2019 Author Share Posted April 15, 2019 Never mind all!!! I got it to work!! Don't know what I did, but it works fine now! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.