public void ConstructDictionaries()
    {
        // Loop through the prefabs list, construct a dictionary
        m_PrefabDictionary = new Dictionary <string, GameObject>();
        for (int i = 0; i < m_PrefabList.Length; i++)
        {
            PrefabKeyValuePair kvp = m_PrefabList[i];

            if (m_PrefabDictionary.ContainsKey(kvp.id))
            {
                Debug.LogWarning("Id " + kvp.id + " is already used for prefab dictionary, omitting this record.");
                continue;
            }

            m_PrefabDictionary.Add(kvp.id, kvp.prefab);
        }

        // Loop through the scripts list, construct a dictionary
        m_ScriptTypeDictionary = new Dictionary <string, Type>();
        for (int i = 0; i < m_ScriptsList.Length; i++)
        {
            ScriptKeyValuePair kvp = m_ScriptsList[i];

            if (m_ScriptTypeDictionary.ContainsKey(kvp.id))
            {
                Debug.LogWarning("Id " + kvp.id + " is already used for script dictionary, omitting this record.");
                continue;
            }

            // Get Type from the associated asset, a bit tricky
            if (kvp.script != null)
            {
                Assembly asm = Assembly.Load(this.GetType().Assembly.FullName);

                if (asm != null)
                {
                    Type type = asm.GetType(kvp.script.name);

                    if (type != null)
                    {
                        m_ScriptTypeDictionary.Add(kvp.id, type);
                        continue;
                    }
                }
            }

            Debug.LogWarning("Id " + kvp.id + " is mapped to an object that isn't a script, omitting this record.");
        }
    }
    public void Initialize()
    {
        if (string.IsNullOrEmpty(scriptPath) == false)
        {
            LuaVariableCache = new LuaTable(ScriptManager.Instance.Env);
            LuaKeyValueCache = new LuaTable(ScriptManager.Instance.Env);
        }

        variableCaches = new Dictionary <string, PrefabVariable>();
        buttonCaches   = new Dictionary <object, string>();
        for (int i = 0; i < Variables.Count; i++)
        {
            PrefabVariable variable = Variables[i];
            variableCaches.Add(variable.Name, variable);

            if (string.IsNullOrEmpty(scriptPath) == false)
            {
                LuaVariableCache[variable.Name] = variable.Value;
            }

            object button = variable.Value;
            if (button is UIButton || button is UIToggle)
            {
                buttonCaches.Add(button, variable.Name);
            }
        }

        keyVauleCaches = new Dictionary <string, PrefabKeyValuePair>();
        for (int i = 0; i < KeyMap.Count; i++)
        {
            PrefabKeyValuePair keyValuePair = KeyMap[i];
            keyVauleCaches.Add(keyValuePair.Key, keyValuePair);

            if (string.IsNullOrEmpty(scriptPath) == false)
            {
                LuaKeyValueCache[keyValuePair.Key] = keyValuePair.Value;
            }
        }
    }