public override void OnEnable() { base.OnEnable(); if (config is null) { config = ProjectConfigurationProvider.LoadOrDefault <ScriptsConfiguration>(); } ScriptAsset = assetTarget as Script; scriptText = File.ReadAllText(AssetDatabase.GetAssetPath(ScriptAsset)); if (config.EnableVisualEditor) { VisualEditor = new ScriptView(config, ApplyRevertHackGUI, ApplyAndImportChecked); VisualEditor.GenerateForScript(scriptText, ScriptAsset); ScriptAssetPostprocessor.OnModified += HandleScriptModified; return; } previewContent = scriptText; if (previewContent.Length > previewLengthLimit) { previewContent = previewContent.Substring(0, previewLengthLimit); previewContent += $"{System.Environment.NewLine}<...>"; } labelTags = ScriptAsset.Lines.OfType <LabelScriptLine>().Select(l => new GUIContent($"# {l.LabelText}")).ToArray(); gotoTags = ScriptAsset.ExtractCommands().OfType <Commands.Goto>() .Where(c => !string.IsNullOrEmpty(c.Path.Name)) .Select(c => new GUIContent($"@goto {c.Path.ToString().Replace(".null", "")}")).ToArray(); }
public ScriptPlaylist(Script script, IScriptManager scriptManager = null) { ScriptName = script.Name; var localizationScript = scriptManager?.GetLocalizationScriptFor(script); var commands = script.ExtractCommands(localizationScript); AddRange(commands); }
private void UpdateSelectedScript() { SaveResources(); map.Clear(); if (!ObjectUtils.IsValid(script)) { return; } var extractedCommands = script.ExtractCommands() .Where(c => c is Commands.PrintText) .Cast <Commands.PrintText>(); foreach (var cmd in extractedCommands) { if (!cmd?.Text?.HasValue ?? true) { continue; } var hash = AudioConfiguration.GetAutoVoiceClipPath(cmd); var label = $"#{cmd.PlaybackSpot.LineNumber}.{cmd.PlaybackSpot.InlineIndex} "; if (!string.IsNullOrEmpty(cmd.AuthorId)) { label += $"{cmd.AuthorId}: "; } label += cmd.Text.DynamicValue ? cmd.Text.DynamicValueText : cmd.Text.Value; var clipPath = PathUtils.Combine(audioConfig.VoiceLoader.PathPrefix, hash); var clipGuid = editorResources.GetGuidByPath(clipPath); var mapItem = new MapItem { Label = new GUIContent(label, label), ClipGuid = clipGuid }; map[hash] = mapItem; } }