Ejemplo n.º 1
0
    public void Load(ObjData obj)
    {
        if (CheckIsActive(obj.sUid) != null)
        {
            return;
        }
        if (!MoveToActive(obj))
        {
            SceneObj sceneObj = new SceneObj(obj);
            sceneObj.status = SceneObjStatus.New;

            GameObject   resObj = null;
            ResourcesObj resourceObj;
            if (ResourcesObjDic.TryGetValue(obj.resPath, out resourceObj))
            {
                resObj = resourceObj.obj;
                resourceObj.CreateIns();
            }
            else
            {
                resObj = Resources.Load <GameObject>(obj.resPath);
            }

            CreateObj(resObj, sceneObj);
            ActiveObjDic.Add(obj.sUid, sceneObj);
        }
    }
Ejemplo n.º 2
0
    private IEnumerator IELoad(ObjData obj)
    {
        SceneObj sceneObj = new SceneObj(obj);

        sceneObj.status = SceneObjStatus.Loading;
        ActiveObjDic.Add(obj.sUid, sceneObj);
        GameObject   resObj = null;
        ResourcesObj resourceObj;

        if (ResourcesObjDic.TryGetValue(obj.resPath, out resourceObj))
        {
            resObj = resourceObj.obj;
            resourceObj.CreateIns();
        }
        else
        {
            ResourceRequest request = Resources.LoadAsync <GameObject>(obj.resPath);
            yield return(request);

            resObj = request.asset as GameObject;
        }

        CreateObj(resObj, sceneObj);
        sceneObj.status = SceneObjStatus.New;
    }
Ejemplo n.º 3
0
    private bool MoveToActive(ObjData obj)
    {
        SceneObj sceneObj;

        if (InActiveObjDic.TryGetValue(obj.sUid, out sceneObj))
        {
            sceneObj.obj.SetActive(true);
            sceneObj.status = SceneObjStatus.New;
            ActiveObjDic.Add(obj.sUid, sceneObj);
            InActiveObjDic.Remove(obj.sUid);
            return(true);
        }
        return(false);
    }