- Home /
How to change an object material using GUI buttons
Hi...
I have a scene with "First Person Controller" to move around, and 3 objects, I have a script to create 3 GUI buttons for 3 materials, that can be used for assigning a material to a selected object...
I need a script hleps me to achieve the following steps:
1- The mouse pointer position should be locked in the center of the screen.
2- An object get highlighted when mouse pointer is over it.
3- Select an object using left mouse button.
4- assign a material to the selected object through the 3 GUI buttons created previously.
Thanks in Advance.
How do you click a GUI nutton(4) if you can't move your mouse pointer(1)?
There are 2 ideas in my $$anonymous$$d to achieve my project...
First one:
Since I'm using "First Person Controller" to move around, so I am able to make my target object in the center of the screen "where the mouse pointer should be"... and in case I can select the object by mouse, then the 3 GUI buttons should be active and the mouse pointer should be free to be used.
Second one:
is to split the whole screen into 2 parts, the big for the scene "where the mouse should be locked" and the small one for GUI buttons at the bottom "where the mouse pointer must be free to move... Here are samples of I what I wish to create
http://www.youtube.com/watch?v=Y4t-C0pH1rs&feature=player_embedded
the 1st video i watched seems to have an array of materials switching when hovered and clicked by the mouse button also the wall has another option to change it's color.
if your having split screen, one thing i know is have to cameras in the scene(the other one without audio listener in it), and adjust the other camera's normalized view port rect and depth.
About splitting screen; although I didn't try it yet, but I think it can be done by specifying screen dimensions "as you say" with one camera... may be I don't know...
Anyway thanks for your interest and advice
Your answer
![](https://koobas.hobune.stream/wayback/20220613080701im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Having script accessing issues 2 Answers
Accessing a Certain Script 1 Answer
Fetching Objects that belongs to other script, with name or tag 1 Answer
How can i make an igniter that ignite objects? 1 Answer
Can't destroy a script. 1 Answer