Exemplo n.º 1
0
 public override void Close()
 {
     WindowMng.RemoveWindow(mWndObject, this);
     OnClose();
     if (mWndObject != null)
     {
         GameObject.Destroy(mWndObject);
         mWndObject = null;
     }
     if (WindowStyle.WS_Ext <= mWindowStyle &&
         mExtBackground != null)
     {
         GameObject.Destroy(mExtBackground);
         mExtBackground = null;
     }
     msInstance = null;
 }
Exemplo n.º 2
0
    public static void LoadLevel(int id)
    {
        uint profileTotalAllocate = Profiler.GetTotalAllocatedMemory();
        uint profileTotalReserved = Profiler.GetTotalReservedMemory();
        long gcTotal = System.GC.GetTotalMemory(false);

        Log.LogInfo("profile totalAllocate:" + profileTotalAllocate + " profile TotalReserved:" + profileTotalReserved + " gc totalAllocate:" + gcTotal);
        Log.LogInfo("start load level:" + id);
        if (FightWnd.Exist)
        {
            FightWnd.Instance.Close();
        }
        //if (StateWnd.Exist)
        //    StateWnd.Instance.Close();
        WindowMng.CloseAll();
        Log.LogInfo("WindowMng.CloseAll();");
        //暂时不允许使用声音管理器,在切换场景时不允许播放
        SoundManager.Instance.StopAll();
        SoundManager.Instance.Enable(false);
        SaveLastLevelData();
        ClearLevelData();
        Log.LogInfo("ClearLevelData");
        Level lev = LevelMng.Instance.GetItem(id);

        Global.GLevelItem = lev;
        Log.LogInfo("Global.GLevelItem = lev;");
        LoadingWnd.Instance.Open();
        Log.LogInfo("LoadingWnd.Instance.Open();");
        Resources.UnloadUnusedAssets();
        GC.Collect();
        if (!string.IsNullOrEmpty(lev.goodList))
        {
            string num    = lev.goodList.Substring(2);
            int    number = int.Parse(num);
            Debug.Log("b" + number);
            PlayMovie("b" + number);
        }
        LevelHelper helper = ins.gameObject.AddComponent <LevelHelper>();

        helper.Load(id);
        Log.LogInfo("helper.load end");
    }
Exemplo n.º 3
0
    public static void LoadLevel(int id, int gate)
    {
        if (FightWnd.Exist)
        {
            FightWnd.Instance.Close();
        }
        //if (StateWnd.Exist)
        //    StateWnd.Instance.Close();
        SoundManager.Instance.StopAll();
        SoundManager.Instance.Enable(false);
        WindowMng.CloseAll();
        SaveLastLevelData();
        ClearLevelData();
        Destroy(GameBattleEx.Instance.gameObject);
        Level lev = LevelMng.Instance.GetItem(id);

        Global.GLevelItem = lev;
        LoadingWnd.Instance.Open();
        LevelHelper helper = ins.gameObject.AddComponent <LevelHelper>();

        helper.Load(id, gate);
    }
Exemplo n.º 4
0
 public void OnClick()
 {
     WindowMng.OnModalClick(transform.parent.parent.gameObject);
 }
Exemplo n.º 5
0
    public void Open()
    {
        //Debug.Log("Open Window:"+PrefabName);
        if (mWndObject)
        {
            Debug.LogError("Window:" + PrefabName + "The window already opened!!!!");
            WindowMng.RemoveWindow(mWndObject, this);
            GameObject.Destroy(mWndObject);//这句话会导致一个界面上的成员变量没清理
            if (WindowStyle.WS_Ext <= mWindowStyle)
            {
                GameObject.Destroy(mExtBackground);
            }
            //return;
        }
#if UNITY_2017 || UNITY_5_5
        mRootUI = GameObject.Find("Canvas");
        if (mRootUI != null)
        {
            if (!CanvasMode())
            {
                mWndObject = GameObject.Instantiate(Resources.Load <GameObject>(PrefabName), Vector3.zero, Quaternion.identity, mRootUI.transform) as GameObject;
            }
            else
            {
                mWndObject = GameObject.Instantiate(Resources.Load <GameObject>(PrefabName));
            }
        }
        else
        {
            mWndObject = GameObject.Instantiate(Resources.Load <GameObject>(PrefabName));
        }
        if (mRootUI != null)
        {
            if (!CanvasMode())
            {
                WndObject.transform.SetParent(mRootUI.transform);
                WndObject.transform.localScale    = Vector3.one;
                WndObject.transform.localRotation = Quaternion.identity;
            }
            RectTransform rectTran = WndObject.GetComponent <RectTransform>();
            if (rectTran != null && rectTran.anchorMin == Vector2.zero && rectTran.anchorMax == Vector2.one)
            {
                if (rectTran.rect.width == 0 && rectTran.rect.height == 0)
                {
                    rectTran.sizeDelta = new Vector2(0, 0);
                }
            }
            if (rectTran != null)
            {
                rectTran.anchoredPosition3D = new Vector3(0, 0, 0);
            }
        }
        else
        {
            //mRootUI = GameObject.Find("Anchor");
            //if (mRootUI != null)
            //    WndObject.transform.SetParent(mRootUI.transform);
        }
#else
        mRootUI = GameObject.Find("Anchor");
        WndObject.transform.parent = mRootUI.transform;
#endif
        WndObject.transform.localScale = Vector3.one;
        //WndObject.transform.localPosition = new Vector3(GetX(), GetY(), GetZ());
        WindowMng.AddWindow(mWndObject, this);

        OnOpen();

        //attention Order
        //mCamera = GameObject.Find("Camera-CloseUp");
        //if (mCamera != null)
        //    mCullingMask = mCamera.GetComponent<Camera>().cullingMask;

        //阻挡UI之后其他的UI响应
        if (mWindowStyle >= WindowStyle.WS_Ext)
        {
            mExtBackground = GameObject.Instantiate(Resources.Load("BackgroundExtWnd")) as GameObject;
            mExtBackground.transform.SetParent(WndObject.transform);
            mExtBackground.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
            mExtBackground.transform.localScale    = Vector3.one;
            mExtBackground.transform.localRotation = Quaternion.identity;
            mExtBackground.transform.SetAsFirstSibling();
        }

        //if (WindowStyle.WS_CullingMask <= mWindowStyle)
        //{
        //    Debug.Log("LayerMask NGUI : = " + LayerMask.NameToLayer("NGUI"));
        //    //attention Order
        //    if (mCamera != null)
        //        mCamera.GetComponent<Camera>().cullingMask = LayerMask.NameToLayer("NGUI");
        //}
        //AutoAdaptGUI();
    }