コード例 #1
0
        public static void ExpandTextTemplateInScripts()
        {
            var log = SelectionExtensions.GetSelectingScriptAssetPath()
                      .Aggregate("", (_s, _c) => _s + _c + ";");

            Debug.Log($"selecting scripts: {log}");

            foreach (var assetPath in SelectionExtensions.GetSelectingScriptAssetPath())
            {
                try
                {
                    var textAsset = AssetDatabase.LoadAssetAtPath <TextAsset>(assetPath);
                    var(text, isSuccess) = ExpandTextTemplate(textAsset.text);
                    if (isSuccess)
                    {
                        var filepath = EditorFileUtils.GetFullFilepath(assetPath);
                        File.WriteAllText(filepath, text);
                        AssetDatabase.ImportAsset(assetPath);
                    }
                }
                catch (System.Exception)
                {
                    Debug.LogWarning($"Failed to Expand TextTemplate in {assetPath}...");
                }
            }
        }
コード例 #2
0
ファイル: TraitsSupporter.cs プロジェクト: tositeru/hinode
        public static void ExpandTraitsInScripts()
        {
            var log = SelectionExtensions.GetSelectingScriptAssetPath()
                      .Aggregate("", (_s, _c) => _s + _c + ";");

            Logger.Log(Logger.Priority.High, () => $"{LOG_PREFIX}selecting scripts: {log}", LOG_SELECTOR);

            foreach (var assetPath in SelectionExtensions.GetSelectingScriptAssetPath())
            {
                try
                {
                    var traitsSupporter = new TraitsSupporter();
                    var result          = traitsSupporter.ExpandInFile(assetPath);

                    File.WriteAllText(traitsSupporter.Filepath, result);
                    AssetDatabase.ImportAsset(assetPath);
                }
                catch (System.Exception e)
                {
                    Logger.LogError(Logger.Priority.High
                                    , () => $"Failed to Expand TextTemplate in {assetPath}..." + System.Environment.NewLine
                                    + "-----"
                                    + e
                                    + "-----"
                                    , LOG_SELECTOR);
                    Debug.LogWarning($"Failed to Expand TextTemplate in {assetPath}...");
                }
            }
        }
コード例 #3
0
 public static bool ValidateExpandTextTemplateInScripts()
 {
     return(SelectionExtensions.GetSelectingScriptAssetPath().Any());
 }