Hi, all . I have 3 sprites named A,B,C. Now I wish after press A with B together, the C will appear, how to write the script? sorry my script is poor. thank you !
1 Answer
1Set up the two buttons, A and B in your OnGUI() function simply check if both are true and if so draw “C”.
// C# Example
using UnityEngine;
public class Example : MonoBehaviour
{
void OnGUI()
{
if(GUI.Button(new Rect(10, 10,100,100),"Button A") &&
GUI.Button(new Rect(10,110,100,100),"Button B") )
{
if(GUI.Button(new Rect(110,60,100,100),"Button C") )
{
// do button c stuff here
}
}
}
}
The Documentation can show you how to display a sprite on each button.
This isn't a free scripting service, you should give it a try yourself and come here when you get stuck. If you don't know how to script at all, you should do some tutorials.
– KhadaHi,Khada,thanks for reply.I looked some tutorials and can write some code but about this question that I don't know the logic in script.
– wensk