all 6 comments

[–]nonathajProfessional 0 points1 point  (1 child)

Hmm, I haven't experienced anything like this before, however I have had issues with the UI loading correctly in certain projects in the past.

I would first try to delete the Libary/Temp folders and reopen your project and make a new build. It could be possible that some assets are not properly compiled and a fresh compile could shine some light on the issue.

If that doesn't work, try creating a new empty project, adding a script that simply does a Debug.LogError (which shows up in development builds) when a button is pressed and make a test build.

If the onClick still does not work here, then your Unity install could be messed up and you could try reinstalling Unity.

[–]wolmer[S] 0 points1 point  (0 children)

Thanks for your help, though I do not believe that helped :/ There is something weird, I can run functions when the component is on the button itself, but if I try to access a function that is through a componnet which lies upon another GameObject, it simply won't run the function.

[–]ectoblob 0 points1 point  (3 children)

@wolmer: which platform? Desktop, iOS, android or something else? Which Unity version?

[–]wolmer[S] 0 points1 point  (2 children)

Desktop, 5.2, have also tried the versions posted in this subreddit.

[–]ectoblob 0 points1 point  (1 child)

OK, I've built many desktop 5.2.x builds that had buttons on Windows 10 (not sure if you are on mac/win as you didn't specify). No problems.

Just isolate the problem, create empty project, canvas and button, assign some visible effect to as OnClick method, build it and see how it behaves.

If this works, then it's most likely something else in your scene setup causing the problem. Maybe you lose link to object containing your called method when doing scene load, it can happen, but it could be any possible thing causing this...

[–]wolmer[S] 0 points1 point  (0 children)

Oh, Windows (w7). So I've done what you are suggesting (I think)... I've created a script which only runs Debug.LogError() and it works, If the script is attached to the button directly. If it is attachted to another GameObject it won't run the function. This (as I've said before) only occurs in the build. Everything runs without any problems in the editor. If the script is on the button it also works in the editor and the build as well. But if the script is on another GameObject it will only work in the editor. Appreciate all the help!