So I want to access a Texture variable that is another script from other script.
public class AssignMaterial : MonoBehaviour {
public Texture required;
void Start ()
{
required = Resources.Load("Textures/Brown") as Texture;
}
}
public class DragHandler : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
AssignMaterial texture;
public void Start()
{
texture = new AssignMaterial();
}
public void OnEndDrag (PointerEventData eventData)
{
Debug.Log(texture.required.name);
}
}
The result is
NullReferenceException: Object reference not set to an instance of an object