Exemplo n.º 1
0
    private void ToggleControls(GameObject prefab)
    {
        // Check if the factory has already instaited this prefab, if so remove it.
        for (int i = 0; i < controlFactory.Modules.Count; i++)
        {
            if (controlFactory.Modules[i].name == prefab.name)
            {
                controlFactory.RemoveModule(i);
                return;
            }
        }

        // Check for max, and return if so.
        if (controlFactory.Modules.Count >= maxControls)
        {
            message = "You have reached the maximum amount of control schemes.\nPlease remove one first.";
            return;
        }

        // If not found, then add it.
        controlFactory.AddModuleByObject(prefab);
    }