subere23

ActivateToolSet

Sep 16th, 2017
462
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class ActivateToolSet : MonoBehaviour {
  6.  
  7. public float scaleFactor = 0.4f;
  8. GameObject cursor;
  9. bool isActive;
  10.  
  11. public List<SpriteRenderer> rend;
  12.  
  13. // Use this for initialization
  14. void Start () {
  15.  
  16. cursor = GameObject.Find("Cursor");
  17. transform.localScale *= scaleFactor;
  18.  
  19. }
  20.  
  21. // Update is called once per frame
  22. void Update()
  23. {
  24. transform.position = cursor.transform.position;
  25. transform.rotation = cursor.transform.rotation;
  26. }
  27.  
  28.  
  29. private void OnEnable()
  30. {
  31. NRSRManager.ObjectFocused += ActivateThis;
  32. NRSRManager.ObjectUnFocused += DeactivateThis;
  33. }
  34.  
  35. private void OnDisable()
  36. {
  37. NRSRManager.ObjectFocused -= ActivateThis;
  38. NRSRManager.ObjectUnFocused -= DeactivateThis;
  39. }
  40.  
  41.  
  42. void ActivateThis()
  43. {
  44. //Debug.Log(gameObject.name + "ATS ActivateThis");
  45. foreach(SpriteRenderer spriteRend in rend)
  46. {
  47. Debug.Log(gameObject.name + "ATS ActivateThis");
  48. spriteRend.enabled = true;
  49. }
  50. }
  51.  
  52. void DeactivateThis()
  53. {
  54.  
  55. foreach (SpriteRenderer spriteRend in rend)
  56. {
  57. Debug.Log(gameObject.name + "ATS DeActivateThis");
  58. spriteRend.enabled = false;
  59. }
  60. }
  61. }
RAW Paste Data