• Unity代码动态创建Timeline


    最近需要通过配置表生成Timeline,自己测试通过,代码如下:

     1 using UnityEditor;
     2 using UnityEngine;
     3 using UnityEngine.Timeline;
     4 
     5 
     6 public class Test : EditorWindow
     7 {
     8     string m_PartID;
     9 
    10     [MenuItem("Assets/TimelineGenerator")]
    11     public static void Init()
    12     {
    13         GetWindow<Test>().Show();
    14     }
    15 
    16     public void OnGUI()
    17     {
    18         GUILayout.BeginVertical();
    19 
    20         GUILayout.BeginHorizontal();
    21         GUILayout.Label("PartID");
    22         m_PartID = GUILayout.TextField(m_PartID);
    23         GUILayout.EndHorizontal();
    24 
    25         if (GUILayout.Button("Generate"))
    26             Generate();
    27 
    28         GUILayout.EndVertical();
    29     }
    30 
    31     void Generate()
    32     {
    33         var asset = TimelineAsset.CreateInstance<TimelineAsset>();
    34         AssetDatabase.CreateAsset(asset, "Assets/Test/test.playable");
    35         var track = asset.CreateTrack<PlayableTrack>(null, "tt");
    36         var clip = track.CreateClip<Talk>();
    37         clip.displayName = "QAQ";
    38         AssetDatabase.SaveAssets();
    39     }
    40 }
  • 相关阅读:
    [IOI2013]Dreaming
    Lost Cows
    Mobile Service
    [POI2005]Bank notes
    [CTSC2007]动物园zoo
    [CF1093F]Vasya and Array
    [雅礼集训 2017 Day1]市场
    [APIO2014]序列分割
    [CEOI2004]锯木厂选址
    [APIO2010]特别行动队
  • 原文地址:https://www.cnblogs.com/liucUP/p/10691369.html
Copyright © 2020-2023  润新知