I’m currently unable to solve this problem, and would really appreciate any help!
This error: “NullReferenceException: Object reference not set to an instance of an object” keeps popping up when trying to copy a value from one object’s variable to another.
I have a game object called Scene1 with this script called sceneDescription attached:
var sceneDescription : String;
var sceneDescArray : String[];
var scenePlayed : boolean;
function Awake () {
sceneDescArray = sceneDescription.Split("\n"[0]);
}
function Update () {
}
I have another game object called SceneControl with this script called sceneControl attached:
import UnityEngine;
import UnityEngine.UI;
import System.Collections;
var globalVariablesObject : GameObject;
var localGlobalVariables : globalVariables;
var dialogState: int;
var sceneStart : GameObject;
var sceneCurrent : GameObject;
var sceneDescription : String;
var sceneDescArray : String[];
var scenePlayed : boolean;
var sceneCanvasText : Text;
function Awake () {
localGlobalVariables = globalVariablesObject.GetComponent(globalVariables);
//init
sceneCurrent = sceneStart;
globalVariablesObject.GetComponent(globalVariables).sceneCurrent = sceneCurrent;
sceneDescArray = sceneCurrent.GetComponent(sceneDescription).sceneDescArray;
dialogState = localGlobalVariables.dialogState;
}
But when I run I keep getting this error: “NullReferenceException: Object reference not set to an instance of an object”
Not sure what I am doing wrong. I simply want to copy the sceneDescArray content from the first object to the second…
Help!