Object reference not set to an instance of an object

Hi,
I want get color of pixel from sprite. It’s my code. What can I do?

using UnityEngine;
using System.Collections;


public class NewBehaviourScript : MonoBehaviour {
   Texture2D b;
    Sprite bin;
    void Start () {

        bin = Resources.Load("kosz", typeof(Sprite)) as Sprite;
        b = bin.texture;
        Color color = b.GetPixel(1, 1);
        Debug.Log(color);
    }

    // Update is called once per frame
    void Update () {
    }
}

I have error which reports me my variable is empty and I don’t know why. My sprite I have in dir called “picture”. I already tried “picture/kosz”,“picture/kosz.jpg”, “kosz”, “kosz.jpg”. What I do wrong?

This is my error: [quote]
NullReferenceException: Object reference not set to an instance of an object
NewBehaviourScript.Start () (at Assets/picture/NewBehaviourScript.cs:18)
[/quote]

Is the “bin” Sprite linked to a GameObject in the editor? If not, try doing:

bin = Instantiate(Resources.Load("kosz", typeof(Sprite))) as Sprite;

Hi,

the sprite HAVE to be in a folder called: Resources