Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class UseButton : MonoBehaviour
- {
- public GameObject sprite1;
- public GameObject sprite2;
- public bool a;//по стандарту фолс, если не задать обратное в старте либо в инспекторе
- void Start ()
- {
- sprite1.gameObject.SetActive(true);
- sprite1.gameObject.SetActive(false);
- a = false;
- }
- void Update ()
- {
- if (Input.GetKeyDown(KeyKode.A))
- {
- a = true;
- }
- if (Input.GetKeyUp(KeyKode.A))
- {
- a = false;
- }
- if (a == true)
- {
- sprite1.gameObject.SetActive(false);
- sprite1.gameObject.SetActive(true);
- }
- else if (a == false)
- {
- sprite1.gameObject.SetActive(true);
- sprite1.gameObject.SetActive(false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement