- Home /
GUI button to NGUI button ?
Hi friends, I'm using a GUI Sprite Button for JUMPING on a mobile game, with this script attached :
using UnityEngine;
[RequireComponent(typeof(GUIElement))]
public class Button : MonoBehaviour
{
public string buttonName = "Fire1"; // The name used for the button
public bool pairedWithInputManager;
private AbstractButton m_Button;
void OnEnable()
{
m_Button = ButtonFactory.GetPlatformSpecificButtonImplementation ();
m_Button.Enable(buttonName, pairedWithInputManager, GetComponent<GUIElement>().GetScreenRect());
}
void OnDisable()
{
// remove the button from the cross platform input manager
m_Button.Disable ();
}
void Update()
{
m_Button.Update ();
}
}
I want to use instead NGUI Button to perform this ;) someone can help me with this ? Thanks in advance !
Comment
Seems like at least a partial duplicate of http://answers.unity3d.com/questions/752159/ngui-guitexturehittest-equivalent.html
Do you need more information than that?
Thanks Rutter for your suggestion, I tried a lot of ideas...so far nothing :(
Answer by RoyalCoder · Aug 04, 2014 at 01:48 PM
Hi guy's the problem is solved ...thanks to ArenMook : [link text][1] [1]: http://www.tasharen.com/forum/index.php?topic=10559.msg49701#msg49701
Example:
bool mIsPressed = false;
public float fireRate= 0.5F;
private float nextFire= 0.0F;
void OnPress (bool isPressed)
{
mIsPressed = isPressed;
}
void Update()
{
if (mIsPressed && Time.time > nextFire)
{
nextFire = Time.time + fireRate;
Instantiate (bullet, spawnPoint.position, spawnPoint.rotation);
audio.Play();
}
}