/// <summary>
        /// 异步加载并实例化资源。
        /// </summary>
        /// <param name="assetName">要加载资源的名称。</param>
        /// <param name="loadAndInstantiateAssetSuccessCallback">加载资源成功回调函数。</param>
        /// <param name="loadAssetFailureCallback">加载资源失败回调函数。</param>
        /// <param name="userData">用户自定义数据。</param>
        public void LoadAndInstantiateAsset(string assetName, LoadAndInstantiateAssetSuccessCallback loadAndInstantiateAssetSuccessCallback, LoadAssetFailureCallback loadAssetFailureCallback, object userData)
        {
#if UNITY_EDITOR
            UnityEngine.Object asset = AssetDatabase.LoadMainAssetAtPath(assetName);
            if (asset != null)
            {
                UnityEngine.Object instance = UnityEngine.Object.Instantiate(asset);
                if (instance != null)
                {
                    if (loadAndInstantiateAssetSuccessCallback != null)
                    {
                        loadAndInstantiateAssetSuccessCallback(assetName, asset, instance, userData);
                    }

                    return;
                }
            }

            if (loadAssetFailureCallback != null)
            {
                loadAssetFailureCallback(assetName, LoadResourceStatus.NotExist, "Can not load and instantiate this resource from asset database.", userData);
            }
#endif
        }
 /// <summary>
 /// 异步加载并实例化资源。
 /// </summary>
 /// <param name="assetName">要加载资源的名称。</param>
 /// <param name="loadAndInstantiateAssetSuccessCallback">加载资源成功回调函数。</param>
 /// <param name="loadAssetFailureCallback">加载资源失败回调函数。</param>
 public void LoadAndInstantiateAsset(string assetName, LoadAndInstantiateAssetSuccessCallback loadAndInstantiateAssetSuccessCallback, LoadAssetFailureCallback loadAssetFailureCallback)
 {
     LoadAndInstantiateAsset(assetName, loadAndInstantiateAssetSuccessCallback, loadAssetFailureCallback, null);
 }
Exemplo n.º 3
0
 /// <summary>
 /// 异步加载并实例化资源。
 /// </summary>
 /// <param name="assetName">要加载资源的名称。</param>
 /// <param name="loadAndInstantiateAssetSuccessCallback">加载资源成功回调函数。</param>
 /// <param name="loadAssetFailureCallback">加载资源失败回调函数。</param>
 /// <param name="userData">用户自定义数据。</param>
 public void LoadAndInstantiateAsset(string assetName, LoadAndInstantiateAssetSuccessCallback loadAndInstantiateAssetSuccessCallback, LoadAssetFailureCallback loadAssetFailureCallback, object userData)
 {
     m_ResourceManager.LoadAndInstantiateAsset(assetName, loadAndInstantiateAssetSuccessCallback, loadAssetFailureCallback, userData);
 }