Exemple #1
0
    public static void Open(string nm, object p = null)
    {
        WM wm = ins;

        if (ins == null)
        {
            Debug.LogError("XXX");
            return;
        }
        if (wm.mWins.Count == 0)
        {
            Win w = wm.mCaches.Find(e => e.name == nm);
            if (w == null)
            {
                w = wm.root.AddChild(Resources.Load <GameObject>("Prefab/" + nm)).GetComponent <Win>();
            }
            else
            {
                wm.mCaches.Remove(w);
            }
            w.gameObject.SetActive(true);
            wm.mWins.Push(w);
            w.GetComponent <Canvas>().sortingOrder = 0;
            w.GetComponent <Canvas>().worldCamera  = wm.cam;
        }
        else
        {
            Win w = wm.mWins.Peek();
            if (w.name == nm)
            {
                w.param = p;
                w.OnInit();
            }
            else
            {
                Win t = wm.mCaches.Find(e => e.name == nm);
                if (t == null)
                {
                    t = wm.root.AddChild(Resources.Load <GameObject>("Prefab/" + nm)).GetComponent <Win>();
                }
                else
                {
                    wm.mCaches.Remove(t);
                }
                t.param = p;
                t.OnInit();
                t.gameObject.SetActive(true);
                wm.mWins.Push(t);
                t.GetComponent <Canvas>().sortingOrder = w.GetComponent <Canvas>().sortingOrder + 30;
                w.GetComponent <Canvas>().worldCamera  = wm.cam;
            }
        }
    }