Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[BUG]Load Timeline Asset from Assetbundle

Discussion in 'Timeline' started by wechat_os_Qy06fvcm1PmXkJd4807uh-IWA, Jan 20, 2020.

  1. wechat_os_Qy06fvcm1PmXkJd4807uh-IWA

    wechat_os_Qy06fvcm1PmXkJd4807uh-IWA

    Joined:
    Jan 9, 2020
    Posts:
    8
    Code (CSharp):
    1. public class ZTest : MonoBehaviour {
    2.     AssetBundle assetBundleP = null;
    3.     AssetBundle assetBundleT = null;
    4.  
    5.     private void OnGUI() {
    6.         #region stepA
    7.         if (GUILayout.Button("Load AB_T", GUILayout.Width(200), GUILayout.Height(150))) {
    8.             string path = Path.Combine(Application.streamingAssetsPath, "Android/testtimeline");
    9.             Debug.Log("path " + path);
    10.             assetBundleT = AssetBundle.LoadFromFile(path);
    11.         }
    12.         #endregion
    13.  
    14.         #region stepB
    15.         if (GUILayout.Button("Load AB_P", GUILayout.Width(200), GUILayout.Height(150))) {
    16.             string path = Path.Combine(Application.streamingAssetsPath, "Android/playabledirector");
    17.             Debug.Log("path " + path);
    18.             assetBundleP = AssetBundle.LoadFromFile(path);
    19.         }
    20.         #endregion
    21.  
    22.         #region stepC
    23.         if (GUILayout.Button("Load P", GUILayout.Width(200), GUILayout.Height(150))) {
    24.             if (assetBundleP == null) {
    25.                 Debug.LogError("Load AB_P Failed, Forgot?");
    26.             } else {
    27.                 GameObject asset = assetBundleP.LoadAsset<GameObject>("Assets/Prefab/PlayableDirector.prefab");
    28.                 var pd = asset.GetComponent<PlayableDirector>();
    29.                 Debug.Log(pd.name);
    30.             }
    31.         }
    32.         #endregion
    33.  
    34.         #region stepD
    35.         if (GUILayout.Button("Load T", GUILayout.Width(200), GUILayout.Height(150))) {
    36.             if (assetBundleT == null) {
    37.                 Debug.LogError("Load AB_T Failed, Forgot?");
    38.             } else {
    39.                 var asset = assetBundleT.LoadAsset<TimelineAsset>("Assets/Prefab/TestTimeline.playable");
    40.                 Debug.Log("asset.outputTrackCount = " + asset.outputTrackCount);
    41.             }
    42.         }
    43.         #endregion
    44.  
    45.     }
    46. }
    a -> b -> d -> c : asset.outputTrackCount == 4
    a -> b -> c -> d : asset.outputTrackCount == 0

    Mabe there is a bug here.

    Here is the test package.
     

    Attached Files: