Log in or register to post comments

using gui buttons

April 18, 2012 - 6:33am #1

hello everyone :)
i was experimenting with the virtual buttons application and i wondered that is it possible to perform the same actions i.e rendering different texture on the teapot with 4 gui buttons rather than the virtual buttons...
is it possible, and how may i be able to do it because iam wanting to change the object with another 3d model and perform the action of changing its color or texture when 4 gui buttons are added... plz help :)

using gui buttons

June 27, 2012 - 2:37am #14

if u would, dont mind if u could post the code where u placed the gui commands in?

thanks in advance

Re: using gui buttons

May 17, 2012 - 7:48pm #13

I've successfully, I do it with disable/enable the GUI script when image target detected.

Re: using gui buttons

May 17, 2012 - 12:32pm #12

Yes and you can set a public variable on the GUI script from the event handler.

So if the GUI is presented using a script called MyGUIScript and the property is showGUI , then you can access this using object.GetComponent().showGUI = true / false.

Re: using gui buttons

May 17, 2012 - 11:53am #11

@waldroid

you have to make a var and make it true only when detecting the target , then you should write something like this in the gui function
if ( var==true) {
/// here you can write your gui code
}

Re: using gui buttons

May 17, 2012 - 7:16am #10

How to make GUI buttons that only appear when the image target detected?
I have made it and attach it to the image target, but the GUI button still appears even though the image target not been detected.

I've tried and not succeeded, please help me.. :(

Re: using gui buttons

May 10, 2012 - 8:35pm #9

thanks ahmed_jamal
i'll try it :)

Re: using gui buttons

May 7, 2012 - 4:15am #8

@waldroid
perhaps you could try and create the gui buttons from the script i.e on the DefaulttrackableEventHandler. im not sure if it will work or not but its worth a try :)

Re: using gui buttons

May 7, 2012 - 4:11am #7

thanks alot kim :)
it worked fine and smoothly :D

Re: using gui buttons

May 7, 2012 - 1:56am #6

How to make GUI buttons that only appear when the image target detected?
I have made it and attach it to the image target, but the GUI button still appears even though the image target not been detected.

can you help me?

Re: using gui buttons

April 19, 2012 - 12:35pm #5

I recommend creating your own script rather than changing either of those. OnGUI is a MonoBehaviour callback, so Unity will call it automatically. All you need to do is create a new script (we recommend C#), add that method, and drag the script onto the ARCamera.

- Kim

Re: using gui buttons

April 19, 2012 - 12:04am #4

i was wondering also that in the ARcamera object, there are 2 scripts containing the onGui function i.e DefaultInitializationErrorHandler.cs and CameraDeviceMenu.cs. where should i add the code to produce gui buttons??? can you kindly elaborate a little bit please??? :/

Re: using gui buttons

April 18, 2012 - 11:27pm #3

thankyou very much David :)
i'll give it a shot and let u know.
and i have another confusion that when we tap the screen while running any ar app, the menu appears on the screen showing the autofocus and flashlight menu at the bottom, is it possible to remove it from the application and how???

Re: using gui buttons

April 18, 2012 - 8:52pm #2

Yes you should be able to accomplish the same thing using Unity's GUI controls. See: http://unity3d.com/support/documentation/Components/GUI%20Scripting%20Guide.html

You'll need to write a script to present the GUI button(s) which inherits from Monobehaviour, and attach this to an active object in your project Hierarchy - the ARCamera is a good candidate for this. Then call the code that you are currently using in your VB event handler from the OnGUI method implemented in that script. You'll need to define the buttons that you are using within OnGUI as such..

	
void OnGUI () {
	if (GUI.Button (new Rect (10,10,150,100), "change the texture")) {
			// render a different texture on the teapot 
	}
}
Log in or register to post comments