Example #1
0
            void HandleGoto(string path)
            {
                var scriptPath  = path.Contains(".") ? path.GetBefore(".") : path;
                var scriptLabel = path.GetAfter(".");

                if (!string.IsNullOrEmpty(scriptPath))
                {
                    var resourcePath = string.IsNullOrEmpty(config.Loader.PathPrefix) ? scriptPath : $"{config.Loader.PathPrefix}/{scriptPath}";
                    var guid         = editorResources.GetGuidByPath(resourcePath);
                    if (string.IsNullOrEmpty(guid))
                    {
                        Debug.LogWarning($"Failed to open `{scriptPath}`: script is not found in project resources. Make sure to add it via the script resources menu.");
                        return;
                    }
                    var assetPath = AssetDatabase.GUIDToAssetPath(guid);
                    if (string.IsNullOrEmpty(assetPath))
                    {
                        Debug.LogWarning($"Failed to open `{scriptPath}`: GUID is not valid. Make sure the record points to a valid asset in the script resources menu.");
                        return;
                    }
                    Selection.activeObject = AssetDatabase.LoadAssetAtPath <Script>(assetPath);
                }
                else if (!string.IsNullOrEmpty(scriptLabel))
                {
                    var line = linesContainer.Children().FirstOrDefault(l => l is LabelLineView labelLine && labelLine.ValueField.value.EqualsFast(scriptLabel)) as LabelLineView;
                    if (line != null)
                    {
                        FocusLine(line);
                        ScrollToLine(line);
                    }
                }
            }
Example #2
0
        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;
            }
        }