- Home /
Remove GUI Buttons in Prime 31 Touch kit.
Hi everyone, I have the Touch kit from Prime 31 This one And theres a demo scene with GUI Buttons and if you press on a GUI Button it activates a function for example you can move the cube now. And I wanna do that the GUI buttons are gone and moving is on right away.
here is the code of activating the moving:
if( GUILayout.Button( "Add Pan Recognizer" ) )
{
var recognizer = new TKPanRecognizer();
// when using in conjunction with a pinch or rotation recognizer setting the min touches to 2 smoothes movement greatly
if( Application.platform == RuntimePlatform.IPhonePlayer )
recognizer.minimumNumberOfTouches = 2;
recognizer.gestureRecognizedEvent += ( r ) =>
{
cube.transform.position -= new Vector3( recognizer.deltaTranslation.x, recognizer.deltaTranslation.y ) / -200;
Debug.Log( "pan recognizer fired: " + r );
};
// continuous gestures have a complete event so that we know when they are done recognizing
recognizer.gestureCompleteEvent += r =>
{
Debug.Log( "pan gesture complete" );
};
TouchKit.addGestureRecognizer( recognizer );
}
Answer by highpockets · Mar 07, 2014 at 09:01 PM
If you want to add the recognizer to the scene without the use of GUI buttons, it is very easy. Just do it in the Start function.
Copy all of the code inside the GUI button conditional (excluding the GUI button conditional ) and put it in the start function
I'm on my phone and it won't let me copy the code, otherwise I would show you the example, but you put everything in the start function from line 3 to line 20 that you have shown above