// Use this for initialization
    void Start()
    {
        fileBrowserUI = (FileBrowserUI)FindObjectOfType(typeof(FileBrowserUI));
        if (fileBrowserUI == null)
        {
            Debug.Log("You are missing the FileBrowserUI object! Unity was unable to find a GameObject with the FileBrowserUI component.");
        }

        StartCoroutine("SetEnclosingFolderColor");
    }
예제 #2
0
    public void Open(Menu p_previousMenu, string p_startPath = "", string p_defaultSaveName = "", params string[] p_extensions)
    {
        Setup();

        if (m_canvas == null)
        {
            Debug.LogError("This file browser has no canvas parent!"); return;
        }
        if (m_uiPrefab == null)
        {
            Debug.LogError("Please assign the UI prefab to this file browser!"); return;
        }

        if (p_previousMenu)
        {
            m_menu.m_previousMenu = p_previousMenu;
        }

        GameObject uiObject = Instantiate(m_uiPrefab, transform, false);

        m_ui = uiObject.GetComponent <FileBrowserUI>();

        if (m_ui == null)
        {
            Debug.LogError("The UI Prefab does not have the FileBrowserUI component!");
            Destroy(uiObject);
            return;
        }

        if (p_defaultSaveName.Length > 0)
        {
            m_mode = BrowserMode.SAVE;
        }
        else
        {
            m_mode = BrowserMode.LOAD;
        }

        m_extensions = p_extensions;

        m_ui.Setup(this, m_mode);
        SetupPath(p_startPath);
        LoadViewer();

        if (m_mode == BrowserMode.SAVE)
        {
            m_ui.UpdateFileName(p_defaultSaveName + "." + m_extensions[0]);
        }

        MenuHandler.Instance.OpenMenu(m_menu);
    }