public void RemoveButtonListener(UIEventListener.VoidDelegate callback)
 {
     for (int i = 0; i < Variables.Count; i++)
     {
         PrefabVariable variable = Variables[i];
         if (variable.Value != null && (variable.Value is UIButton || variable.Value is UIToggle))
         {
             UIWidgetContainer button = variable.Value as UIToggle;
             if (button == null)
             {
                 button = variable.Value as UIButton;
             }
             if (button == null)
             {
                 continue;
             }
             UIEventListener listener = UIEventListener.Get(button.gameObject);
             listener.onClick -= callback;
         }
     }
 }
    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;
            }
        }
    }