Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

Commit ca4d0be

Browse files
committed
feat(scalar): change to unity
1 parent cb1cca9 commit ca4d0be

File tree

546 files changed

+115677
-1843
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

546 files changed

+115677
-1843
lines changed

projects/dsb/scalar/.gitignore

Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,57 @@
1-
# Logs
2-
logs
3-
*.log
4-
npm-debug.log*
5-
yarn-debug.log*
6-
yarn-error.log*
7-
pnpm-debug.log*
8-
lerna-debug.log*
9-
10-
node_modules
11-
dist
12-
dist-ssr
13-
*.local
141

15-
# Editor directories and files
16-
.vscode/*
17-
!.vscode/extensions.json
18-
.idea
19-
.DS_Store
20-
*.suo
21-
*.ntvs*
22-
*.njsproj
2+
# Unity.gitignore by ignofierplus
3+
.utmp/
4+
/[Ll]ibrary/
5+
/[Tt]emp/
6+
/[Oo]bj/
7+
/[Bb]uild/
8+
/[Bb]uilds/
9+
/[Ll]ogs/
10+
/[Uu]ser[Ss]ettings/
11+
*.log
12+
*.blend1
13+
*.blend1.meta
14+
/[Mm]emoryCaptures/
15+
/[Rr]ecordings/
16+
/[Aa]ssets/Plugins/Editor/JetBrains*
17+
*.DotSettings.user
18+
.vs/
19+
.gradle/
20+
ExportedObj/
21+
.consulo/
22+
*.csproj
23+
*.unityproj
2324
*.sln
24-
*.sw?
25+
*.suo
26+
*.tmp
27+
*.user
28+
*.userprefs
29+
*.pidb
30+
*.booproj
31+
*.svd
32+
*.pdb
33+
*.mdb
34+
*.opendb
35+
*.VC.db
36+
*.pidb.meta
37+
*.pdb.meta
38+
*.mdb.meta
39+
sysinfo.txt
40+
mono_crash.*
41+
*.apk
42+
*.aab
43+
*.unitypackage
44+
*.unitypackage.meta
45+
*.app
46+
crashlytics-build.properties
47+
InitTestScene*.unity*
48+
/ServerData
49+
/[Aa]ssets/StreamingAssets/aa*
50+
/[Aa]ssets/AddressableAssetsData/link.xml*
51+
/[Aa]ssets/Addressables_Temp*
52+
/[Aa]ssets/AddressableAssetsData/*/*.bin*
53+
/[Aa]ssets/Unity.VisualScripting.Generated/VisualScripting.Flow/UnitOptions.db
54+
/[Aa]ssets/Unity.VisualScripting.Generated/VisualScripting.Flow/UnitOptions.db.meta
55+
/[Aa]ssets/Unity.VisualScripting.Generated/VisualScripting.Core/Property Providers
56+
/[Aa]ssets/Unity.VisualScripting.Generated/VisualScripting.Core/Property Providers.meta
57+
/[Aa]ssets/[Ii]nit[Tt]est[Ss]cene*.unity*

projects/dsb/scalar/.vsconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"version": "1.0",
3+
"components": [
4+
"Microsoft.VisualStudio.Workload.ManagedGame"
5+
]
6+
}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
using UnityEngine;
2+
using Ink.Runtime;
3+
using UnityEngine.UI;
4+
using TMPro;
5+
6+
public class Conversation : MonoBehaviour
7+
{
8+
[SerializeField]
9+
private TextAsset _inkJsonAsset;
10+
private Story _story;
11+
12+
[SerializeField]
13+
private TextMeshProUGUI _textField;
14+
15+
//[SerializeField]
16+
//private VerticalLayoutGroup _choiceButtonContainer;
17+
18+
//[SerializeField]
19+
//private Button _choiceButtonPrefab;
20+
21+
[SerializeField]
22+
private Color _normalTextColor;
23+
24+
[SerializeField]
25+
private Color _thoughtTextColor;
26+
27+
void Start()
28+
{
29+
StartStory();
30+
}
31+
32+
private void StartStory()
33+
{
34+
if (_inkJsonAsset == null) {
35+
Debug.LogError("Ink JSON Asset is not assigned.");
36+
return;
37+
}
38+
_story = new Story(_inkJsonAsset.text);
39+
Debug.Log("Story started.");
40+
DisplayNextLine();
41+
}
42+
43+
public void DisplayNextLine()
44+
{
45+
Debug.Log("DisplayNextLine called.");
46+
if (_story.canContinue)
47+
{
48+
string text = _story.Continue(); // gets next line
49+
text = text?.Trim(); // removes white space from text
50+
Debug.Log("Story Text: " + text);
51+
ApplyStyling();
52+
53+
if (_textField != null) {
54+
_textField.text = text; // displays new text
55+
} else {
56+
Debug.LogError("Text field is not assigned.");
57+
}
58+
}
59+
else
60+
{
61+
Debug.Log("Story cannot continue.");
62+
}
63+
//else if (_story.currentChoices.Count > 0)
64+
//{
65+
// DisplayChoices();
66+
//}
67+
}
68+
69+
/*
70+
private void DisplayChoices()
71+
{
72+
// checks if choices are already being displaye
73+
if (_choiceButtonContainer.GetComponentsInChildren<Button>().Length > 0) return;
74+
75+
for (int i = 0; i < _story.currentChoices.Count; i++) // iterates through all choices
76+
{
77+
78+
var choice = _story.currentChoices[i];
79+
var button = CreateChoiceButton(choice.text); // creates a choice button
80+
81+
button.onClick.AddListener(() => OnClickChoiceButton(choice));
82+
}
83+
}
84+
85+
Button CreateChoiceButton(string text)
86+
{
87+
// creates the button from a prefab
88+
var choiceButton = Instantiate(_choiceButtonPrefab);
89+
choiceButton.transform.SetParent(_choiceButtonContainer.transform, false);
90+
91+
// sets text on the button
92+
var buttonText = choiceButton.GetComponentInChildren<TextMeshProUGUI>();
93+
buttonText.text = text;
94+
95+
return choiceButton;
96+
}
97+
98+
void OnClickChoiceButton(Choice choice)
99+
{
100+
_story.ChooseChoiceIndex(choice.index); // tells ink which choice was selected
101+
RefreshChoiceView(); // removes choices from the screen
102+
DisplayNextLine();
103+
}
104+
105+
void RefreshChoiceView()
106+
{
107+
if (_choiceButtonContainer != null)
108+
{
109+
foreach (var button in _choiceButtonContainer.GetComponentsInChildren<Button>())
110+
{
111+
Destroy(button.gameObject);
112+
}
113+
}
114+
}
115+
*/
116+
117+
private void ApplyStyling()
118+
{
119+
if (_story.currentTags.Contains("thought"))
120+
{
121+
_textField.color = _thoughtTextColor;
122+
_textField.fontStyle = FontStyles.Italic;
123+
}
124+
else
125+
{
126+
_textField.color = _normalTextColor;
127+
_textField.fontStyle = FontStyles.Normal;
128+
}
129+
}
130+
}

projects/dsb/scalar/Assets/Conversation.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)