0
\$\begingroup\$

I'm interested in setting up a small Unity open source project so that non-Unity devs can contribute.

I would limit their involvement to making a small change to only one script, say adding a new entry to a dictionary or list that a method then loops through.

My question is: is this even possible? Theoretically, if someone cloned a Unity repo from GitHub, would they be able to make changes to a script in the project without having the Editor installed? I foresee there being issues when opening the script and having the Miscellaneous Files issue pop up in Visual Studio so contributors might have to work without proper Intellisense.

\$\endgroup\$
6
  • \$\begingroup\$ If they have the UnityEngine.dll (or equivalent) installed, their code editor should be able to get the relevant intellisense symbols from that. But I don't know if Unity's ToS allows distributing engine components like that separate from the editor or a published game. \$\endgroup\$
    – DMGregory
    Commented Sep 8, 2023 at 16:57
  • \$\begingroup\$ Yes, I was wondering specifically about the ToS. I'll look more into it. Thanks for your help! \$\endgroup\$
    – waffles13
    Commented Sep 8, 2023 at 17:00
  • \$\begingroup\$ You may also be able to make your own library that just has stub functions for any of the parts of the Unity API you expect users might need to reference, without providing any implementation / just returning default values everywhere. That would be enough to get intellisense and compile-time checks working, as long as they don't need to run the code on real data. I am not a lawyer and can't comment on whether that runs afoul of any reproduction/reverse engineering protections, but I'd suspect just mocking the published API for testing purposes shouldn't violate any intellectual property. \$\endgroup\$
    – DMGregory
    Commented Sep 8, 2023 at 17:07
  • \$\begingroup\$ Thanks again for your input. I was thinking of just ignoring the Intellisense issue and having contributors modify the script independent of any reference to the Unity API (which I believe they could do if they were just adding a new entry to a list). And then just manually fixing any code errors inadvertently caused by contributors and manually doing the builds myself. \$\endgroup\$
    – waffles13
    Commented Sep 8, 2023 at 17:18
  • \$\begingroup\$ You mention "adding a new entry to a dictionary or list". What data type is the entry? \$\endgroup\$
    – Kevin
    Commented Sep 8, 2023 at 17:59

1 Answer 1

3
\$\begingroup\$

You said your data is strings. Since you haven't explained the nature of the data, I'll describe an example scenario: let's say you can talk to random NPCs in a town, and each time you talk to an NPC, they display a random line of dialog text. In this example, we want players to be able to add new lines of random dialog.

Rather than having non-Unity devs contribute by editing a script, you could put the data in a text file. Continuing with the example, let's say there's a Guard NPC with unique lines of dialog. We could simply create a file "GuardRandomDialog.txt" with one line of dialog on each line of the file:

GuardRandomDialog.txt

Man, my feet are getting sore.
Move along, there's nothing to see here.
I really wish someone would clean the barracks...
Please stay out of trouble.

With this setup, we can load the dialog with one line of code:

IEnumerable<string> guardRandomDialog = File.ReadLines("Dialog/GuardRandomDialog.txt");

We would then create a separate text file for each type of NPC with random dialog. Simple and easy to work with!


What if the data needs to be in key-value pair format? In this case, you can still use a text file, where the first word of each line is the key. For example, a simple localization file:

GuardScriptedDialog.txt

go-see-king "The king has requested your presence in the throne room."
find-blacksmith "You can find the blacksmith in the south part of town, just east of the fountain."
garden-no-entry "Only members of the royal household can enter the garden."

For this approach, you would need a few lines of additional code to parse the entries from the file into a dictionary. I don't have time to write up an example at the moment, but you can find plenty of examples online.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .