- Home /
The question is answered, right answer was accepted
Click a button that changes the script used by a gameobject
I have a list of buttons and a rawimage and the buttons are meant to affect what video is played on the rawimage and I was wondering if it's possible for the buttons to have a script that basically goes like this;
Once button 1 is clicked it changes the script used by rawimage from whatever script is being used to script1 and same with button2 changing the script used by rawimage to script2 and this has to be done for 6 buttons.
Is this possible?
Answer by Ki4Chan · Aug 19, 2017 at 02:56 PM
Didn't get what exactly you are looking but you can check this link.
http://answers.unity3d.com/questions/41116/switch-script-on-game-object.html
Ah sorry for not clarifying better. The rawimage the rawimage in the middle has a script tied to it that allows this link to play "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4"
but I'd like it so that whenever you press one of the buttons the video link changes and I thought the easiest way to do that is for different scripts to be loaded depending on which button is pressed
So I tried a different but similar way to what I was trying to describe.
I made 2 separate cinema screens and made it so that they either get enabled or disabled depending on which button gets pressed. And duplicated the script only changing na$$anonymous$$g certain na$$anonymous$$g conventions and the url so that both cinemas play different movies to ensure the script works. And it worked the way I wanted.