Ejemplo n.º 1
0
        public ResourceObserver LoadAsset(string path)
        {
            ResourceObserver retOb    = null;
            ResourceState    resState = this.GetResState(path);

            /*
             * resState.req.isLoaded will be loading or isLoaded.
             * if it fail, it will be remove by funciton ResLoadEndCall
             */
            if (null != resState && null != resState.req && resState.req.isLoaded)
            {
                retOb = resState.AddObserver(null);
            }
            else
            {
                UnityEngine.Object ret = m_resLoader.Load(path);
                if (null != ret)
                {
                    if (null == resState)
                    {
                        resState = new ResourceState(this);
                        ulong reqId = this.GenReqId();
                        resState.req = ResourceRequest.CreateRequest(m_resLoader, path, ret, reqId);
                        m_resStates.Add(path, resState);
                        retOb = resState.AddObserver(null);
                    }
                    else
                    {
                        retOb = resState.AddObserver(null);
                        resState.req.SetRes(ret);
                    }
                }
            }
            return(retOb);
        }