Пример #1
0
        /// <summary>
        /// コンバート処理開始時の共通処理
        /// </summary>
        /// <param name="srcFiles">コンバート元ファイル</param>
        static private void ConvertStarter(LinterRepository linterRepository, params string[] srcFiles)
        {
            Debug.Log("Start script convert");
            // スクリプトコンバータの生成
            var scriptConverter = new Script2Chunk();

            scriptConverter.SetLinterRepository(linterRepository);

            int successCount = 0;
            int failedCount  = 0;

            UpdateProgress(successCount + failedCount, srcFiles.Length);
            foreach (var baseFilePath in srcFiles)
            {
                var filePath         = baseFilePath.Replace("\\", "/");
                var srcLocalFilePath = filePath.Replace(SrcFolderPath, "");
                var dstLocalFilePath = Path.ChangeExtension(srcLocalFilePath, ".asset");
                if (ConvertAndSave(scriptConverter, dstLocalFilePath, filePath))
                {
                    ++successCount;
                }
                else
                {
                    ++failedCount;
                }
                UpdateProgress(successCount + failedCount, srcFiles.Length);
            }
            EditorUtility.ClearProgressBar();
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            Debug.Log(string.Format("End convert Total file: {0}, success: {1}, failure: {2}",
                                    srcFiles.Length, successCount, failedCount));
        }
Пример #2
0
    public IEnumerator ScenarioPlayByText()
    {
        Debug.Log("スクリプトテキストからのチャンク生成と実行");
        // スクリプトコンバータの生成
        var converter = new CommandScripter.Script2Chunk();

        converter.SetLinterRepository(new Scenario.LinterRepository());
        // スクリプトテキストの読み込み・チャンク生成
        var scriptText = Resources.Load <TextAsset>("CommandScripts/Sources/WaitSample");
        var chunk      = converter.ParseScript("WaitSample", scriptText.text);

        Assert.IsNotNull(chunk);
        // コマンドコントローラ生成
        var playerGo = new GameObject();
        var player   = playerGo.AddComponent <CommandScripter.CommandController>();
        var comRepo  = playerGo.AddComponent <Scenario.CommandRepository>();

        player.Initialize(comRepo);
        // チャンクの実行
        player.Execute(chunk, () =>
        {
            Debug.Log("Play end");
        });
        Assert.IsTrue(player.IsPlaying);
        while (player.IsPlaying)
        {
            yield return(null);
        }
    }
Пример #3
0
    public void Convert()
    {
        var converter = new CommandScripter.Script2Chunk();

        converter.SetLinterRepository(new Scenario.LinterRepository());
        var scriptText = Resources.Load <TextAsset>("CommandScripts/Sources/WaitSample");
        var chunk      = converter.ParseScript("WaitSample", scriptText.text);

        Assert.IsNotNull(chunk);
    }
Пример #4
0
        /// <summary>
        /// 指定パスのファイルのコンバートを試み、
        /// 成功時にDstFolderPath以下の適切な箇所に生成したファイルを保存します
        /// </summary>
        /// <param name="converter">スクリプトコンバータ</param>
        /// <param name="dstLocalFilePath">出力先パス</param>
        /// <param name="fullSrcFilePath">コンバート元ファイルのフルパス</param>
        /// <returns>コンバートを正常に終えたかどうか</returns>
        static private bool ConvertAndSave(Script2Chunk converter, string dstLocalFilePath, string fullSrcFilePath)
        {
            Debug.Log("Target:" + dstLocalFilePath);
            System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
            watch.Start();
            var chunk = converter.ParseScript(fullSrcFilePath, LoadTxtFile(fullSrcFilePath));

            if (chunk == null)
            {
                Debug.LogError(fullSrcFilePath + " : Failure create chunk");
                watch.Stop();
                Debug.Log("Parse time:" + watch.ElapsedMilliseconds + "ms");
                return(false);
            }
            watch.Stop();
            Debug.Log("Parse time:" + watch.ElapsedMilliseconds + "ms");

            watch.Reset();
            watch.Start();
            // ScriptAssetの生成
            CommandInfoChunk targetChunk = TryGetAsset <CommandInfoChunk>(DstScriptFolderPath, dstLocalFilePath, null);

            if (targetChunk != null)
            {
                targetChunk.Setup(chunk);
                EditorUtility.SetDirty(targetChunk);
            }
            else
            {
                CreateAsset(chunk, DstScriptFolderPath, dstLocalFilePath, "commandScript/script", null, false);
                EditorUtility.SetDirty(chunk);
            }
            watch.Stop();
            Debug.Log("Create script asset:" + watch.ElapsedMilliseconds + "ms");
            return(true);
        }