static public int GetAsset(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         AssetBundleLoadAssetOperationFull self = (AssetBundleLoadAssetOperationFull)checkSelf(l);
         var ret = self.GetAsset();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Ejemplo n.º 2
0
    IEnumerator LoadAssetAsync <T>(string assetBundleName, string assetName, System.Action <T, bool> callback) where T : UnityEngine.Object
    {
        LoadAssetBundle(assetBundleName, GetLevel(assetBundleName, assetName));
        AssetBundleLoadAssetOperation request = new AssetBundleLoadAssetOperationFull(assetBundleName, assetName, typeof(T));

        m_InProgressOperations.Add(request);
        yield return(StartCoroutine(request));

        T obj = (T)request.GetAsset <UnityEngine.Object>();

        InitHideFlag(obj);
        if (callback == null || callback.Target == null || "null".Equals(callback.Target.ToString()))
        {
            yield break;
        }
        callback.Invoke(obj, IsValid(obj));
        callback = null;
    }
Ejemplo n.º 3
0
    protected IEnumerator LoadSpriteAsync(string assetBundleName, string spritename, System.Action <Sprite> OnLoad, System.Action OnPackError)
    {
        // This is simply to get the elapsed time for this phase of AssetLoading.
        float startTime = Time.realtimeSinceStartup;

        // Load asset from assetBundle.
        AssetBundleLoadAssetOperationFull request = AssetManager.LoadAssetAsync(assetBundleName, spritename, typeof(Sprite), true);

        if (request == null)
        {
            yield break;
        }
        yield return(StartCoroutine(request));

        // Get the asset.
        Sprite s = request.GetAsset <Sprite>(spritename);

        if (s != null)
        {
            if (null != OnLoad)
            {
                OnLoad(s);
            }
        }
        else
        {
            if (null != OnPackError)
            {
                OnPackError();
            }
        }

        // Calculate and display the elapsed time.
        float elapsedTime = Time.realtimeSinceStartup - startTime;

        Debug.Log(spritename + (s == null ? " was not" : " was") + " loaded successfully in " + elapsedTime + " seconds");
    }