I have 2 scripts Test_Json
and GetJson
attached to a Game Object
which contains only function Start ()
.I created a JSON in Test_Json
. And trying to access created.But it shows
NullReferenceException: Object reference not set to an instance of an object
GetJson.Start () (at Assets/JSON Tests/UnityScript/GetJson.js:8)
But when accessing it in the function Update
then it works completely fine.So how to know which script is getting executed first …Same goes for function Update ()
.
Here are my scripts ::
GetJson
#pragma strict
public var test_json:Test_Json;
function Start ()
{
test_json=FindObjectOfType(typeof(Test_Json));
print(test_json.I.ToString());
print(test_json.I["name"]);
print(test_json.I["Symbol"]);
print(test_json.I["Bond"]);
}
function Update () {
}
**Test_Json**
#pragma strict
import SimpleJSON;
var test_JsonString:String;
var test:String;
var symbol:String;
var Element1:String;
var Element2:String;
var I:SimpleJSON.JSONClass;
function Start ()
{
test="Sanket";
symbol="SANK";
Element1="Element1";
Element2="Element2";
I=new JSONClass();
I["name"]=test;
I["Symbol"]=symbol;
I["Bond"]["Element1"].Add(Element1);
I["Bond"]["Element2"].Add(Element2);
}
function Update ()
{
// var N = JSONNode.Parse(test_JsonString);
}