Add AC_Subtitles plugin - Subtitle support for H and Touch scenes #13
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
IllusionMods/Aicomi-Translation!13
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "subsplug"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull Request Overview
Adds a new BepInEx IL2CPP plugin to provide subtitles in H and Touch scenes by hooking scene initialization and rendering a subtitle canvas with localized text.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@ -0,0 +1,110 @@using BepInEx;File.ReadAllLines will throw if AutoTranslatorConfig.ini is missing; guard with File.Exists (or use File.ReadLines with an existence check) to avoid an unhandled exception when AutoTranslator is installed but the config file is absent.
@ -0,0 +36,4 @@canvas.renderMode = RenderMode.ScreenSpaceOverlay;canvas.sortingOrder = -2; // Draw under UI_canvasGroupCmp = gameObject.AddComponent<CanvasGroup>();_canvasGroupCmp.blocksRaycasts = false;The GameObject created in MakeCanvas does not have a Canvas component; GetComponent() will return null and accessing canvas.renderMode will throw a NullReferenceException. Add the Canvas component before using it, e.g., replace GetComponent with AddComponent or null-check and add if missing.
@ -0,0 +49,4 @@_subtitleGo.name = "SubtitleText";DestroyImmediate(_subtitleGo.GetComponent<UIBindData>());DestroyImmediate(_subtitleGo.GetComponent<TMP_SpriteAnimator>());DestroyImmediate is discouraged at runtime and can cause unexpected behavior; use Destroy for runtime object/component cleanup. Replace DestroyImmediate calls with Destroy to align with Unity runtime best practices.
@ -0,0 +71,4 @@}catch (Exception e){SubtitlesPlugin.Log.LogError("Failed to create subtitle canvas! I am die, thank you forever.\n" + e);The error message is unclear and unprofessional. Replace it with a concise, actionable message that includes context and the exception, e.g., 'Failed to create subtitle canvas. Subtitles will be disabled for this scene.' and append the exception.
@ -0,0 +113,4 @@if (_canvasGroupCmp.alpha <= 0)_subtitleCmp.text = "";}CanvasGroup.alpha is decremented/incremented without clamping, allowing it to drift below 0 or above 1. Clamp the value to [0, 1] to avoid negative or >1 alpha values that can lead to inconsistent behavior.
@ -0,0 +118,4 @@else{if (_canvasGroupCmp.alpha < 1)_canvasGroupCmp.alpha += Time.deltaTime * 4;CanvasGroup.alpha is decremented/incremented without clamping, allowing it to drift below 0 or above 1. Clamp the value to [0, 1] to avoid negative or >1 alpha values that can lead to inconsistent behavior.