Hi
I am new to unity and building my second unity App with some basic tutorials i followed. I am stuck in a issue where i am accessing a string in which a url is stored. I need to use the same value in another script but it gives me a NullReferenceException: Object reference not set to an instance of an object
I have searched for the error in the forum and was able to find couple of them,but none worked for me. Way i am accessing the string is as follows:
Script 1:
using UnityEngine;
using System.Collections;
publicclass ScriptA : MonoBehaviour {
public string bundleurl;
// Use this for initialization
void Start () {
bundleurl = “www.google.com”;
}
// Update is called once per frame
void Update () {
}
}
Script 2:
using UnityEngine;
using System.Collections;
publicclass ScriptB : MonoBehaviour {
public ScriptA scriptAB;
publicstring x;
// Use this for initialization
void Start () {
x = scriptAB.bundleurl;
Debug.Log(x);
}
// Update is called once per frame
void Update () {
}
}
Thanks in Advance.