(WARNING) Technical Post: How B1NARY works.
As I am writing, I decided to make a full reference manual this past month and knock out the future GitHub Use Manual at the same time.
just a VN, B1NARY is platform for new VN's and is designed to be flexible, modular, fairly straightforward to use. [/p][/p][/p][/p]Spank Engine Commands[/p]Writer’s Script: [/p][/img]
[/p][/p][/p][/p][/p]Text:[/p]Additive Text: [/p]Allows each line to be added onto the panel one line at a time.[/p][/p][/p][/p][/p]Italic: [/p]Makes text italic. Requires Start and End Brackets[/p][/p][/p][/p]Bold: [/p]Makes text bold inside the brackets. Requires Start and End Brackets[/p][/p][/p]Characters / Object Control: [/p]Character Focus: [/p]Character focus is a central point of the way the systems work. Lines below the Character Focus command will show the Name of the Character that is focused on in the name template of the UI. [/p]This will also affect expressions. [/p]If the last focus was the object that you want to get expressions or animations from, then you do not need to set focus again. [/p]There is currently no limit on the lines between focus switch and animations/expressions.[/p][/p]NOTE: All current objects and items are required to be at least deactivated in scene for the system to see them.[/p][/p][/p][/p][/p][/p][/p][/p][/p][/p][/p][/p][/img][/p][/p]Spawning:[/p]Spawning and positioning of a character. This is for any object. If they are characters, they will have set audio channels in the Component Menu in the Object. Center Position is .5 with 0 being Left off Screen, and 1 being on the Right Side.[/p][/p][/p][/p]Example: [/p][/p]Position would be almost the far left side of the screen.[/p][/img]
[/p][/p]Non Object Spawning: [/p]When you need a voice without an object to position you can use this command. The command is slightly altered to allow you add an audio channel.[/p][/p][/p][/p][/img]
[/p]Movement of Objects:[/p]Movement of Objects is one speed with a fade on the start and end. Code is open to adjust this or add other options. EX: Moving Focus Object around.[/p][/p]Center Position is .5 with 0 being Left off Screen, and 1 being on the Right Side.[/p][/p]If negative number, it will be off screen on the left and if positive over 1 it will be off screen on the right.[/p][/p][/p][/p]Example: [/p][/p][/img]
[/p][/p]Live 2D Eye Tracking: [/p]Live 2D Models have the capability to track an object, allowing for the writer to control who or what the models are collectively looking at. You can even add multiple focus objects to allow models to look at different things. [/p][/p]The item can be controlled via script using x and y axis using this command: [/p][/p][/p]Example:[/p]Follow Cube Function.[/p][/img]
[/p][/img]
[/p][/img][/p]In order for it to properly work, the model prefabs have to be in the scene prefab attached to the models and rigged properly. This design is to keep things straight forward and allow for maximum adaptability. [/p][/p][/p]Change Names of Models: [/p]You can change the name of a current model by using this command. After the name change it will go by the name you assign until the change of Scenes. Changing Scenes resets character layouts. [/p]Also audio is attached to the model and will remain the same. If you change the name of a non model object, the former assignment of audio channel remains. [/p][/p]Command: [/p][/p][/p][/p]Example:[/p][/img]
Expressions: [/p]Expressions are motions used by Live 2D to change the expression of the facial features. Motions are not the same as animations. These would be considered Toggles. You should even be able to toggle different outfits this way. They are for now only for live 2D and 3D models. [/p]The names of these are based on Unity’s naming scheme when the characters are rigged in Unity. This can also be used for 3D models.[/p]The expression used is based on name and which focus the character is set up. [/p][/p][/p][/p]Example: [/p][/p][/p][/p][/p] (This activates the smile motion for the object named Asterella)[/p][/p][/p]Animations: [/p]Animations are named via the Unity animation system and require a full rig set up. These can be looped animations, or one time animations and can be used at any time. Focus as well is required to be on the model in question. You can also rename these using Unity.[/p][/img][/p][/p][/p]Example: [/p][/p][/p][/p][/p][/img]
[/p][/p]Activating and Deactivating Objects and Characters:[/p]These two commands utilize the object activate and deactivate function with game objects in scene. Normally this was introduced for performance optimization and UI components that are custom (Binary / Non Binary Choice panel is a good example). Two sub commands: char for character models, and gameobject for non model items. [/p]For character models, use the spawnChar command to activate them. [/p][/p][/p][/p][/p]Example:[/p][/img]
Question: Can you use this functionality to create object based transitions?! YES! We do already. [/p][/p][/p][/p][/p]Example:[/p][/img]
[/p][/p]Choices: [/p]Choices are the core of any good branching narrative. Add on the ability to save flags in the save files for future selections, and you have the tools to further your interaction with players. [/p]Choices are the closest to full time programming that you will get. You can go as simple or as complex as you want. [/p][/p]Commands: [/p][/p]Choice Basic Structure: [/p]This is the basic structure of s a simple choice. { } Indicate full actionable items, and the [ ] brackets denote the sub choice optional content. After the choice bracket, a second set of { } brackets will be all the options in the below format. Any commands can be used inside these brackets and stacked. [/p][/p][/p][/p][/p][/p]Everything inside these brackets is a part of Option 1 Choice. You can go as far as you would like. [/p][/p][/p][/p]Note: you should reset character focus for each choice as a precaution. Bottom of [/p]your choice will.[/p] continue at the end of the choice assembly. [/p][/p][/p]Bracket above is end of choice block. [/p][/p][/p]Set Flags: [/p]Flags are commands and flags that you want to retain in the save file for later, allowing additional content for more diversity of narration. The player picked up a pickle from the fridge, and you set a flag to mark that he did pick up that pickle. In several scenes down that road, you can add the flag and make a section of writing only for players that picked up that pickle. First you have to set the bool (program speak) for the flag using true and false. This allows more flexibility with the tiers of information saved. In the save, it will save whether the flag is true or false for future interactions.[/p]You can also nest choices inside of choices without breaking the system. So have fun![/p][/p]Basic Commands: [/p][/p][/p][/p]You need both a false and true statement. [/p][/p][/p][/p][/p][/p][/p][/p]Below is a solid example of nested choices with booleans set. The boolean will be saved so you can be hours into the story and be able to pull up this decision. [/p][/img]
[/p][/p][/p][/p][/p][/p][/p][/img][/p][/p][/p]Backgrounds: [/p]Backgrounds are handled via Unity Components. Changing them via script is fairly easy. Changing Scene and Changing background are two completely different processes. This provides an instant change of background, and will reset upon scene change. The transition is instant but you can code in some fade animations for your project. [/p]The file tree is very important for the backgrounds. [/p]This can be adjusted in the code for other projects. For B1NARY, the base tree it looks in is /Resources/Backgrounds.[/p][/p][/p]Commands: [/p][/p][/p][/img][/p][/p]Scenes: [/p]Changing scenes will change to premade scenes in Unity. This will follow a door close and open animation and allow preset mats like post processing changes, different models, or a base background. [/p]Changing scenes also resets character spawns, positions, and any audio not shared between two scenes. [/p]The system will search the Unity Standard Scene Folder for the exact name. [/p][/p]Commands:[/p][/p][/p][/p][/p][/p][/img]
[/p][/p]ChangeScript:[/p]changeScript allows access to a user level .txt file that is nested in Unity’s default /StreamingAssets/Docs [/p][/p][/p][/p][/img]
[/p][/p]changeScript: Skipping Lines[/p]You can command the narration to skip to a specific line. This is manual, so if you change the script, you will need to alter this with the new line number.[/p][/p][/p][/p][/img][/p][/p]UI and Themes: [/p]UI themes are user changeable via a theme tool that plugs into the entire UI so you can pick and choose colors for every section of the UI. You don’t even require Unity Editor to change them. The main priority of the themes is to match the color scheme of the background to allow the UI to blend further into the background itself.[/p]A user can adjust color tones in Streaming Assets if they understand XML. [/p]The writer can change a theme whenever they want to allow the colors to match backgrounds. However, any user can change the UI theme in options and override the default. [/p][/p]Themes are found in XML Format in /Assets/StreamingAssets/Color Formats[/p][/p]To properly use the theme engine, you have to manually put in the UI Theme Handler Script as a component in the Image and set the color option you want it to follow. It benefits the colors by ensuring the image is white and has no transparency by default (This allows control of both color and transparency of each sub category. [/p][/p][/img]
[/p][/p]Color Themes[/p][/p][/p]Click on the B1NARY tab in upper Unity Menu.
[/*]Create New Theme (This will make a new XML File in Color Formats)
[/*]Adjust colors for each labelled section based on preference.
[/*]Be sure to hit the save button to ensure the settings are locked in.
[/*]
[/img]
[/img]
[/img]
[/p][/p]Commands: [/p]Once these themes are made and ready to use, you can use the command to set the default theme in a scene. Users can manually change this theme in options and it will remain locked to the user controlled theme. However, if the user goes back to default, it will use the theme specified in the script for the scene. [/p]These themes can be switched mid script and there is no fade currently. I may add a small fade transition to make things cleaner. [/p][/p][/p][/p][/img]
[/p][/p][/p]Audio System:[/p]The audio system is setup to be simple to use and modular by design. Some design compromises have had to be decided. There are basic subsections that comprise the system:[/p]Voice Acting Lines System (VALS)
[/*]Sound Libraries
[/*]Audio Channels (Unity)
[/*]Audio Channels (Models)
[/*]
[/img]
[/img]
Example: [/p]Male Domain.txt has to have a folder in the Voice folder named Male Domain. [/p][/img]
Each audio file is labeled by the line number it sits on. Example above shows the line spoken “Ceiling…” That audio file would be labeled as simply “13”. If you add additional commands that change the line that voice line is on, you have to relabel them all to match the line change.[/p]I understand this is tedious by nature. However, to ensure things are simple, efficient on resources, we decided this was the best route to provide Voice Acting files that can easily be dropped in. Imagine dropping in different language files post game release![/p]We have two tools. One that is a stand alone exe file, and one built into Unity to change the names of all the files in that folder. [/p][/p]Note: Mentioned later in Translation Section, both the English Base and the Switched Language Folders must mirror exactly. [/p][/p][/p]Voice Lines Overlap:[/p]Voice lines will overlap by default if they are played back to back. However, there is a command to cease this behavior.[/p][/p]{stopvoices: true}[/p][/p][/p]{stopvoices: false}[/p][/p][/p][/p]Audio Formats: [/p]All audio formats that Unity uses can be used. Good ones are .ogg (small size), and .wav (large but compatible across OSes). [/p][/img]
[/img]
[/p][/img]
[/p][/p][/p]Sound Libraries: [/p]Sound libraries are unity scriptable objects, set up to increase performance and allow granular control over audio files per scene. Each Scene has its own Sound Library.[/p]The main Script System will use this list to pull audio files into the scene. If there is not a reference of the file in the scene sound library, the file will not play. [/p][/img]
[/p]Mixer Group and Audio Channel Control
[/*]Starting Volume
[/*]Granular Pitch Control and Variance.
[/*]Looping Options
[/*]Scene Transition Handling (Do you want it to cut off on scene change or carry over to the next scene?)
[/*]
[/img]
NOTE: I would recommend keeping the option to destroy the audio when scene changing unless its a very specific sound you want to carry over.[/p][/p]Additionally, in order to properly feed audio files between scenes, the same audio file needs to be in the next scenes Sound Library. [/p][/p]There is some room in the code for audio to add a volume control in the command but it was not currently needed for the project. [/p][/p][/p]Audio Start / Stop: [/p]All of the files in the Sound Library can be started, stopped, and faded in and out, directly from the Writers Script.[/p]All audio files have a start and stop feature, but come with fade by default. You can manually adjust this via the command. [/p][/p][/p]Audio Fade:[/p][/p]Fade in: [/p][/p][/p][/p][/p][/img][/p]Fade Out:[/p]If the sound is set to loopable in the Library, you will have to fade it out. The command is as follows:[/p][/p][/p][/p]Example:[/p][/img][/p][/p]Audio Channels: [/p]Audio channels are Unity based, and we rely on them. The mixer groups add user control over sections of audio, and you can adjust it as much as you need to. For B1NARY, we have groups for general audio, and specific characters in game. [/p]They are coded in, and then attached to the mixer groups. The Settings are found in /Assets/Scripts/Audio/SoundSyncer.cs[/p]Some are hard coded, like Master, Music, SFX, UI.[/p]The rest can be added and assigned to characters, or other channels. The hard code is for the options panel. [/p][/img]
/Assets/Scripts/Options Panel/Sound/ SoundOptionsBehavior.cs is where you can attach new channels. Below is where the CS file is attached to the Unity Channels. [/p][/img]
[/p][/p]Binary Non Binary: [/p]Gender Option is hardcoded into B1NARY’s systems. However, you can simply not use it you don’t need it. Mostly it’s to allow gender neutral options when you pick male or female sex route. [/p][/p][/p][/img]
[/p][/p]Language Translation Audio and Scripts: [/p]Language translation is set up to be modular and easy to add to. In order to keep things easy, the translation folders must mirror scripts and audio. The folder trees must mirror the default language’s tree (Doesn’t have to be english, but currently the default is English) [/p]In order to properly have all languages to switch on the fly, the scripts need to be line for line mirrors of each other. [/p][/p]Writing Script Location:[/p][/p][/p]Language Audio files location: [/p][/p][/img]
[/img]
[/img]
[/p]You can control the language swap via the options panel, and customize many features. You can even add new language options. [/p][/p]Code: [/p][/p][/img]
[/img]
[/p][/p]Textbox Language Globalizer: [/p]For UI Buttons, Panels, and Titles, including UI based PDA Text, the globalizer script and unity component can be activated so when you switch languages, they switch to the language you require. The language translation is NOT automatic. You will have to manually put in the translation into the text boxes below. [/p][/img]
Note: Without the editor, users can add voice lines for each language by using the normal VALS system and labeling the folders to mirror the english version! Just ensure the new folder is labeled (EX: German) in the Language Packs Folder. [/p]If the audio file is missing for the added language, the system will automatically play the audio file from the default folder. This behavior is identical to the Writers Script.[/p][/p][/p]Achievements / Unlocks:[/p]Like choice blocks, Achievements and unlocks help add some player interaction. The unlocks and steam achievements are both set up a bit different and have different purposes. [/p]Locks are saved and react in real time. There are two basic types. [/p]Local Unlocks that save to the save file and Local Prefs (Unity)
[/*]Steam Network Achievements Using Steamworks.
[/*]
[/img]
Command: [/p][/p][/p]Example:[/p][/img]
[/img][/p]Steam vs Offline Version: [/p]Steam versions are set up for Steam only, and will not work outside of steam. However, there is an offline only version that can be activated via the Unity Editors Project Settings in the Player Options. [/p]Script Compilation Symbol: [/p][/p]Once complete, steamworks will be disabled, and builds after will work offline. PDA and other unlocks work the same on offline and steam versions. [/p][/img][/p][/p][/p]PDA Unlock Flags:[/p]The PDA is your source of information in the game and it uses the unlocks to dynamically add new information as you progress through the story. When you unlock new content, the PDA will even activate a blinking light and leave a ‘notification’. The information is organized and saved no just in the save file, but in the Unity Config file in the B1NARY Document folder. [/p]For Mac the location is: /user/Library/Application Support/Coffee and Cookies Dev Team/B1NARY/config.xml[/p]For Windows: /user/AppData/LocalLow/Coffee and Cookies Dev Team/B1NARY/config.xml[/p][/img]
There are 3 Categories of Flags: [/p]Gallery
[/*]Map
[/*]CharProfile
[/*]
[/img]
[/p][/p]Example: If malemcprofile is flagged to unlock, the lock box toggler on profile picture, the first page of information are both removed at the same time. [/p][/p]The CrossScene will keep track of all flags in the prefab. [/p][/img][/img]
Example below is the location of Locked Box Covering Page 1 of the malemcprofile. [/p][/img]
[/p]Example: malemcprofile unlocked in the PDA[/p][/img]
Example: Notification when a flag is unlocked. These are not automatic. You can manually control them, and they are translated to all the languages you choose. [/p][/img]
Example:[/p]Using Notification Behavior Script can activate with the flag’s name allows an alert to the player that new content is available and unlocked. I recommend adding the category in the notification to make finding the information easier. [/p]Like for mcmaleprofile, the text for the notification is “NPC Profile Unlocked: You.” It indicates that the new unlock is in the Profiles Tab under the NPC tab.[/p] [/img][/p][/p]