using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.Timeline;
using System.IO;
using UnityEngine.Playables;
public class ExtractTimelineText
{
[MenuItem("Tools/提取剧情文字")]
static void Extract(){
Editor_LuaConfig.Instance().Init();
string fullPath = "Assets/Resources/Story"; //路径
string txtPath = Application.dataPath + "/dialog.txt";
int storyCount = 0;
//获取指定路径下面的所有资源文件
if (Directory.Exists(fullPath)){
DirectoryInfo direction = new DirectoryInfo(fullPath);
FileInfo[] files = direction.GetFiles("*",SearchOption.TopDirectoryOnly);
// Debug.Log(files.Length);
StreamWriter writer;
FileInfo file = new FileInfo(txtPath);
writer = file.CreateText();
for(int i=0;i<files.Length;i++){
if (files[i].Name.EndsWith(".meta")){
continue;
}
if(!files[i].Name.EndsWith(".prefab"))
continue;
// Debug.Log( "Name:" + files[i].Name ); //打印出来这个文件架下的所有文件
string prefabPath = fullPath + "/" + files[i].Name;
GameObject tempObj = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) as GameObject;
if(tempObj == null){
Debug.LogWarning("not found prefab, name: " + prefabPath);
}else{
PlayableDirector playableDirector = tempObj.GetComponent<PlayableDirector>();
if(playableDirector == null)
continue;
writer.WriteLine("------story name " + files[i].Name + "------");
timeline 相关代码
最新推荐文章于 2025-05-12 17:31:53 发布

最低0.47元/天 解锁文章
1237

被折叠的 条评论
为什么被折叠?



