コード例 #1
0
        public bool UpdateLoadingState()
        {
            if (m_IsDone)
            {
                return(true);
            }

            if (!m_AssetBundle.IsLoadingDone)
            {
                return(false);
            }

            m_Request ??= m_AssetBundle.LoadAsset(m_AssetName, m_AssetType);

#if UNITY_EDITOR
            if (!(m_Request is EditorAssetBundle.EditorAssetBundleRequest) && !m_Request.isDone)
            {
                return(false);
            }
#else
            if (!m_Request.isDone)
            {
                return(false);
            }
#endif

            m_Asset     = m_Request.asset;
            m_AssetType = null;
            m_Request   = null;
            m_IsDone    = true;
            return(true);
        }
コード例 #2
0
 public void Load()
 {
     _loaded = true;
     if (_asset == null)
     {
         _asset = _bundle.LoadAsset(_path);
     }
 }
コード例 #3
0
        public IEnumerator InitMaterials()
        {
            IAssetBundle ab = m_Loader.LoadAssetBundle("minecraft/materials");

            yield return(ab.AsyncHandler);

            AsyncAsset <Material> asset;

            asset = ab.LoadAsset <Material>("chunkmaterial.mat");

            while (!asset.IsDone)
            {
                yield return(null);
            }

            ChunkMaterial = asset.Asset;

            this.Log("加载Chunk材质球");

            asset = ab.LoadAsset <Material>("liquidmaterial.mat");

            while (!asset.IsDone)
            {
                yield return(null);
            }

            LiquidMaterial = asset.Asset;

            this.Log("加载Liquid材质球");

            asset = ab.LoadAsset <Material>("blockentitymaterial.mat");

            while (!asset.IsDone)
            {
                yield return(null);
            }

            BlockEntityMaterial = asset.Asset;

            this.Log("加载BlockEntity材质球");
        }
        /// <summary>
        /// Create just the root object from the asset, will still need to apply all serialized data to the object.
        /// </summary>
        /// <returns></returns>
        protected object CreateRoot()
        {
            if (_bundle == null)
            {
                return(null);
            }

            var resourceId = _info.GetString("sp*id");
            var obj        = _bundle.LoadAsset(resourceId);

            if (obj == null)
            {
                return(null);
            }

            obj = UnityEngine.Object.Instantiate(obj);
            var pobj = ObjUtil.GetAsFromSource <IPersistantAsset>(obj);

            return((object)pobj ?? (object)obj);
        }
コード例 #5
0
        void IDeserializationCallback.OnDeserialization(object sender)
        {
            if (_bundle == null)
            {
                return;
            }

            var resourceId = _info.GetString("sp*id");
            var obj        = _bundle.LoadAsset(resourceId);

            if (obj == null)
            {
                return;
            }

            obj = UnityEngine.Object.Instantiate(obj);

            foreach (var pobj in ComponentUtil.GetComponentsFromSource <IPersistantAsset>(obj))
            {
                pobj.OnDeserialize(_info, _context, _bundle);
            }
        }