Exemplo n.º 1
0
    /// /////////////////////////////////////////////////////////////////////////////////////////////////////////
    ///                              Message Box 管理
    /// /////////////////////////////////////////////////////////////////////////////////////////////////////////
    public UIMessageBox CreateMessageBox(string path)
    {
        if (string.IsNullOrEmpty(path))
        {
            return(null);
        }
        char[]   seprator = { '/', '\\' };
        string[] paths    = path.Split(seprator, System.StringSplitOptions.RemoveEmptyEntries);
        string   boxName  = paths[paths.Length - 1];

        Object prefab = Resources.Load(path);

        if (prefab == null)
        {
            Debug.LogWarning("GUI prefab " + path + " could not found!");
            return(null);
        }

        GameObject pobjMessageBox = Object.Instantiate(prefab) as GameObject;

        pobjMessageBox.transform.SetParent(uiRoot.transform, false);
        //pobjMessageBox.transform.localScale = Vector3.one;
        //pobjMessageBox.transform.localPosition = Vector3.zero;
        //pobjMessageBox.transform.localEulerAngles = Vector3.zero;
        pobjMessageBox.name = boxName;

        GameObject obj = new GameObject();

        obj.transform.SetParent(pobjMessageBox.transform, false);
        //obj.transform.localPosition = Vector3.zero;
        //obj.transform.localScale = Vector3.one;
        obj.layer = pobjMessageBox.layer;
        obj.AddComponent <BoxCollider>().size = new Vector3(10000f, 10000f, 1f);

        UIMessageBox box = pobjMessageBox.GetComponent <UIMessageBox>();

        m_pqueMessageBox.Enqueue(box);
        box.Create();
        //WorldManager.Instance.EnableEvent(false);
        return(box);
    }