Advertisement
KorolevDmitry123

Untitled

Apr 12th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class UseButton : MonoBehaviour
  5. {
  6. public GameObject sprite1;
  7. public GameObject sprite2;
  8. public bool a;//по стандарту фолс, если не задать обратное в старте либо в инспекторе
  9. void Start ()
  10. {
  11. sprite1.gameObject.SetActive(true);
  12. sprite1.gameObject.SetActive(false);
  13. a = false;
  14. }
  15. void Update ()
  16. {
  17. if (Input.GetKeyDown(KeyKode.A))
  18. {
  19. a = true;
  20. }
  21. if (Input.GetKeyUp(KeyKode.A))
  22. {
  23. a = false;
  24. }
  25. if (a == true)
  26. {
  27. sprite1.gameObject.SetActive(false);
  28. sprite1.gameObject.SetActive(true);
  29. }
  30. else if (a == false)
  31. {
  32. sprite1.gameObject.SetActive(true);
  33. sprite1.gameObject.SetActive(false);
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement