void SetThisWeekSprite(){
tk2dSpriteCollectionData data = Resources.Load("UI_Collection", typeof(tk2dSpriteCollectionData)) as tk2dSpriteCollectionData;
tk2dSprite sprite = GetComponent<tk2dSprite>();
//sprite.collection = data;
sprite.SwitchCollectionAndSprite(data,data.GetSpriteIdByName("All_Time_Button_Un"));
AllTime.GetComponent<tk2dButton>().buttonUpSprite = "All_Time_Button_Un";
AllTime.GetComponent<tk2dButton>().buttonDownSprite = "All_Time_Button_Un";
AllTime.GetComponent<tk2dButton>().buttonPressedSprite = "All_Time_Button_Un";
AllTime.GetComponent<tk2dSprite>().spriteId = sprite.GetSpriteIdByName("All_Time_Button_Un");
ThisWeek.GetComponent<tk2dButton>().buttonUpSprite = "This_Week_Button";
ThisWeek.GetComponent<tk2dButton>().buttonDownSprite = "This_Week_Button";
ThisWeek.GetComponent<tk2dButton>().buttonPressedSprite = "This_Week_Button";
ThisWeek.GetComponent<tk2dSprite>().spriteId = sprite.GetSpriteIdByName("This_Week_Button");
}
That's the entire function.
NullReferenceException: Object reference not set to an instance of an object
GameOverGUI.SetThisWeekSprite () (at Assets/Scripts/GameOverGUI.cs:100)
GameOverGUI.Init (Int32 score, Boolean tf) (at Assets/Scripts/GameOverGUI.cs:78)
The nullReference comes on this line:
sprite.SwitchCollectionAndSprite(data,data.GetSpriteIdByName("All_Time_Button_Un"));