I need to access my dictionary from another scene. How would I go about doing that. I posted the code with the inventory in it below. I have been using static references to access different variables across classes but I cant bring up my inventory window in another scene. You can ignore any commented out code. Thanks in advance
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Pauser : MonoBehaviour {
public static Pauser pauser;
private bool paused = false;
public Rect position;
// private bool inventoryWindowToggle = false;
private Rect inventoryWindowRect = new Rect(300,100,410,410);
//private Dictionary
public Dictionary<int,string> inventoryNameDictionary = new Dictionary<int, string> ();
void Awake()
{
pauser = this;
DontDestroyOnLoad(transform.gameObject);
inventoryNameDictionary.Add(0,string.Empty);
inventoryNameDictionary.Add (1, string.Empty);
// inventoryNameDictionary.Add (2, null);
// inventoryNameDictionary.Add (3, null);
// inventoryNameDictionary.Add (4, null);
// inventoryNameDictionary.Add (5, null);
// inventoryNameDictionary.Add (6, null);
// inventoryNameDictionary.Add (7, null);
// inventoryNameDictionary.Add (8, null);
}
ItemClassScript itemObject = new ItemClassScript();
WeaponClassScript weaponObject = new WeaponClassScript();
// Update is called once per frame
void Update () {
if(Input.GetKeyUp(KeyCode.P))
{
paused = !paused;
}
if(paused)
Time.timeScale = 0;
else
Time.timeScale = 1;
}
void OnGUI()
{
if (paused)
// inventoryWindowToggle = GUI.Toggle (new Rect (800, 50, 100, 50), inventoryWindowToggle, "Inventory");
inventoryWindowRect = GUI.Window(0,inventoryWindowRect, inventoryWindowMethod,"Inventory");
//
// if(inventoryWindowToggle)
// {
// inventoryWindowRect = GUI.Window(0,inventoryWindowRect, inventoryWindowMethod,"Inventory");
// }
}
public void inventoryWindowMethod(int windowId)
{
if(Collector.collector.curOre == 1)
inventoryNameDictionary[0] = itemObject.ore.icon;
if(Collector.collector.curGold == 1)
inventoryNameDictionary[1] = itemObject.gold.icon;
//inventoryNameDictionary [1] = weaponObject.sword1.icon;
//inventoryNameDictionary [2] = potion.name;
GUILayout.BeginArea(new Rect(10,50,390,400));
GUILayout.BeginHorizontal ();
GUILayout.Button(inventoryNameDictionary[0], GUILayout.Height (50));
GUILayout.Button (inventoryNameDictionary[1], GUILayout.Height (50));
// GUILayout.Button (inventoryNameDictionary[2], GUILayout.Height (50));
// GUILayout.EndHorizontal ();
//
// GUILayout.BeginHorizontal ();
// GUILayout.Button (inventoryNameDictionary[3], GUILayout.Height (50));
// GUILayout.Button (inventoryNameDictionary[4], GUILayout.Height (50));
// GUILayout.Button (inventoryNameDictionary[5], GUILayout.Height (50));
// GUILayout.EndHorizontal ();
//
// GUILayout.BeginHorizontal ();
// GUILayout.Button (inventoryNameDictionary[6], GUILayout.Height (50));
// GUILayout.Button (inventoryNameDictionary[7], GUILayout.Height (50));
// GUILayout.Button (inventoryNameDictionary[8], GUILayout.Height (50));
GUILayout.EndHorizontal ();
GUILayout.EndArea ();
}
}