示例#1
0
 private void Update()
 {
     if (HasStarted && !IsDone)
     {
         DownloadEvents.DownloadProgressUpdate(Progress);
     }
 }
示例#2
0
    void OnAssetDownloaded(GameObject loadedGameObject)
    {
        DownloadEvents.DownloadEnd();

        if (loadedGameObject)
        {
            if (m_activeModel)
            {
                Destroy(m_activeModel);
            }
            m_activeModel = loadedGameObject;

            SetLayerRecursively(m_activeModel, LayerMask.NameToLayer("3D"));
        }
    }
示例#3
0
        /// <summary>
        /// Shows the progress on screen, if ShowProgress is set to <c>true</c>.
        /// </summary>
        //protected void OnGUI()
        //{
        //    if (!ShowProgress || !HasStarted || IsDone)
        //    {
        //        return;
        //    }
        //    if (_centeredStyle == null)
        //    {
        //        _centeredStyle = GUI.skin.GetStyle("Label");
        //        _centeredStyle.alignment = TextAnchor.UpperCenter;
        //    }
        //    var centeredRect = new Rect(Screen.width / 2f - 100f, Screen.height / 2f - 25f, 200f, 50f);
        //    GUI.Label(centeredRect, string.Format("Downloaded {0:P2}", Progress), _centeredStyle);
        //}

        /// <summary>
        /// Downloads an asset.
        /// </summary>
        /// <returns><c>true</c>, if asset was downloaded, <c>false</c> otherwise.</returns>
        /// <param name="assetURI">Asset URI.</param>
        /// <param name="assetExtension">Asset extension.</param>
        /// <param name="onAssetLoaded">On asset loaded event.</param>
        /// <param name="onTexturePreLoad">On texture pre load event.</param>
        /// <param name="options">Asset loading options.</param>
        /// <param name="wrapperGameObject">Wrapper <see cref="UnityEngine.GameObject"/> to load the asset into.</param>
        public bool DownloadAsset(string assetURI, string assetExtension, ObjectLoadedHandle onAssetLoaded = null, TexturePreLoadHandle onTexturePreLoad = null, AssetLoaderOptions options = null, GameObject wrapperGameObject = null)
        {
            if (HasStarted && !IsDone)
            {
                return(false);
            }

            AssetURI          = assetURI;
            AssetExtension    = assetExtension;
            WrapperGameObject = wrapperGameObject;

            DownloadEvents.DownloadStart();

            StartCoroutine(DoDownloadAsset(assetURI, assetExtension, onAssetLoaded, options, wrapperGameObject));
            return(true);
        }