Simple request (hopefully!)

Hi all,

Firstly let me apologise if this question appears a bit lame. It’s probably very straightforward but as someone with virtually no scripting experience it’s a bit of a challenge.

Basically I have a line of C# script that executes a function through a GUI button:

if (GUI.Button (new Rect (210, 80,170, 40), “open”))

This displays a button in play mode as set out above but I want to use it on a UI button that I already have in place with an OnClick event. The script I have has no attributes that I can choose on the OnClick function, so my question is how can I adjust the script to do that?

I should add that this is part of a plugin that I purchased via the Asset Store but I can’t get hold of the vendor to ask him.

Hope someone can help me out.

Thanks

unfortunately your attempting to get the old legacy OnGUI to function with a new canvas based button…

you might get somewhere by stripping out the contents of the if ( “if(…condition…){…this bit…}”) into a function and assigning that function to the button’s OnClick event… it’s a “might” because it really depends on what the old button code was trying to do.

It’s trying to load.a pdf from within a streaming assets folder. Thank you so much for your reply. It’s certainly a start!

I’ve now had this answered by the vendor. Thank you.

For future reference, set the Method to Public and drop it in a UnityUI button, it’s a lot easier.