0

I am getting the

NullReferenceException: Object reference not set to an instance of an object

for both rows that feature the SendEmail button, regardless of wich button I assign in the inspector. Any ideas? Thanks in advance!

I don't think this represents a duplicate, because in this code are two exactly identical button funtions. One works (TakePhoto), the other one not so much (SendEmail).

Edited to take Bijans and Bidous comments into account, dosen't fix it.

public class Picture : MonoBehaviour {

public Button TakePhoto;
public Button SendEmail;

void Start () {

    TakePhoto.onClick.AddListener (TakePhotoTask);

    SendEmail.onClick.AddListener (SendEmailTask);

}

void Update () {

    if (ssCount == 0) {

        SendEmail.interactable = false;

    } else if (ssCount == 3) {

        TakePhoto.interactable = false;

    }

}
somejonus
  • 124
  • 1
  • 13
  • SendEmail.GetComponent – Bizhan Jan 20 '17 at 10:42
  • `GetComponent` probably returns `null` – Bidou Jan 20 '17 at 10:43
  • @Bijan I edited the code, the error persists. Any ideas? – somejonus Jan 20 '17 at 11:43
  • 1
    SendButton is null even though you assign it in the inspector? Search your scene for multiple instances of this script. You have probably accidently added more Components with this script where the Button isnt assigned. You can also do a Debug.Log(gameObject.name) to see who is using the script – Fredrik Schön Jan 20 '17 at 11:53
  • @Fredrik Not one but two instances were present on different objects. How ever that happened, thank you so much! – somejonus Jan 20 '17 at 11:57

0 Answers0