Hi,
I have few prefabs. Each prefab has attach script:
private KeyCode e, q;
public float degree;
private void Awake()
{
e = KeyCode.E;
q = KeyCode.Q;
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(e))
{
degree -= 90f;
}
if (Input.GetKeyDown(q))
{
degree += 90f;
}
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(degree, 0f, 0f), Time.deltaTime * 5f);
}
It works very great if I use keys E and Q, but I want use for this too buttons. One button will change degree for -=90f, second button for +=90f.
I add this two buttons to scene. Now I have question for that. How I can make this? If I add this from my Assets folder to OnClick() in inspector for buttons in hierarchy, I don’t have any variables to change, or function to run.