playMaker

Author Topic: How to access a GUI button inside a script?  (Read 997 times)

Adam Z

  • Full Member
  • ***
  • Posts: 207
How to access a GUI button inside a script?
« on: August 13, 2019, 11:18:49 PM »
So I have this script:
Code: [Select]
void OnGUI () {
// Enable Word warp
GUI.skin.label.wordWrap = true;
// Make a background box
GUI.Box(new Rect(10,10,300,150), "Chat with a Chatbot");
// Make output label
GUI.Label (new Rect (20, 30, 280, 40), Output_Text);
// Make a text field that modifies Input_Text.
Input_Text = GUI.TextField (new Rect (20, 100, 280, 20), Input_Text, 100);
// If send button or enter pressed
if(((Event.current.keyCode == KeyCode.Return)||GUI.Button(new Rect(250,130,50,20),"Send")) && (Input_Text != "")) {
// Prepare Variables
// You don't need to care, wether Only Jurassics or only Program #'s Variables
// are changed. This is managed immediate intern every time you change a global
// variable in Program # or Jurassic.
// bot.jscript_engine.SetGlobalValue("abc",15);

request.rawInput = Input_Text;
request.StartedOn = DateTime.Now;
result = bot.Chat(request);
Output_Text = result.Output;
Input_Text = "";

// Gather Variables
// bot.jscript_engine.GetGlobalValue<string>("abc");
}
}

And I need to access GUI.Button "Send". I tried dragging the script into a State, but I'm not sure what to select to access that button. Any thoughts?

Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to access a GUI button inside a script?
« Reply #1 on: August 14, 2019, 01:56:27 AM »
Hi,

 You can't, you'll need to switch to the new Unity UI

Recreate this UI using the new UI system and it will all be a lot easier and maintainable.


Bye,

 Jean