Adventure Creator Wikia
Advertisement

This script swaps out your default Journal, Menu and Conversation Menus with an alternative set when the game's language is not set to anything other than the original.

To use it, make sure your Menu Manager has Menus named "Journal", "Menu" and "Conversation" as well as an alternative set named "Journal_Alt", "Menu_Alt" and "Conversation_Alt". Then place it in a script file named "ChangeMenusWithLanguage" and attach to a GameObject in your AC scene.

This is useful if e.g. we want to change the Menus to ones that use a different font when using a certain language.

It is intended for demonstration only - you'll almost certainly want to amend it in a real production.





/*
 * This script swaps out your default Journal, Menu and Conversation Menus with an alternative set
 * when the game's language is not set to anything other than the original.
 *
 * To use it, make sure your Menu Manager has Menus named "Journal", "Menu" and "Conversation", 
 * as well as an alternative set named "Journal_Alt", "Menu_Alt" and "Conversation_Alt".
 *
 * This is useful if e.g. we want to change the Menus to ones that use a different font when using a certain language.
 * 
 * It is intended for demonstration only - you'll almost certainly want to amend it in a real production.
 */

using UnityEngine;
using System.Collections;
using AC;

public class ChangeMenusWithLangage : MonoBehaviour
{
    
    private void OnEnable ()
    {
        EventManager.OnChangeLanguage += OnChangeLanguage;
    }
    
    
    private void OnDisable ()
    {
        EventManager.OnChangeLanguage -= OnChangeLanguage;
    }
    
    
    private void OnChangeLanguage (int languageIndex)
    {
        if (languageIndex == 0)
        {
            // Language '0', use original set of menus.
            AC.PlayerMenus.GetMenuWithName ("Journal").isLocked = false;
            AC.PlayerMenus.GetMenuWithName ("Menu").isLocked = false;
            AC.PlayerMenus.GetMenuWithName ("Conversation").isLocked = false;

            // And lock the alternate set
            AC.PlayerMenus.GetMenuWithName ("Journal_Alt").isLocked = true;
            AC.PlayerMenus.GetMenuWithName ("Menu_Alt").isLocked = true;
            AC.PlayerMenus.GetMenuWithName ("Conversation_Alt").isLocked = true;
        }
        else
        {
            // Use alternate set of menus.
            AC.PlayerMenus.GetMenuWithName ("Journal_Alt").isLocked = false;
            AC.PlayerMenus.GetMenuWithName ("Menu_Alt").isLocked = false;
            AC.PlayerMenus.GetMenuWithName ("Conversation_Alt").isLocked = false;

            // And lock the original set
            AC.PlayerMenus.GetMenuWithName ("Journal").isLocked = true;
            AC.PlayerMenus.GetMenuWithName ("Menu").isLocked = true;
            AC.PlayerMenus.GetMenuWithName ("Conversation").isLocked = true;
        }
    }

}
Advertisement