Skip to content

Commit 97c0569

Browse files
merged in line with internal master branch
1 parent f149ccc commit 97c0569

32 files changed

+256
-66
lines changed

FONT_EULA.pdf.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
# <a href="https://www.youtube.com/watch?v=pmECrkdzHzQ">Watch the video tutorial</a>
2+
<a href="https://www.youtube.com/watch?v=pmECrkdzHzQ"><img src="https://img.youtube.com/vi/pmECrkdzHzQ/0.jpg" alt="mod.io" width="420"/></a>
3+
14
<a href="https://mod.io"><img src="https://beta.mod.io/images/branding/modio_logo_bluewhite.svg" alt="mod.io" width="360" align="right"/></a>
2-
# mod.io Unity Plugin
3-
[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/modio/modio-unity/blob/main/LICENSE.md)
5+
# Mod.io Unity Plugin
6+
[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/modio/modio-unity/blob/master/LICENSE)
47
[![Discord](https://img.shields.io/discord/389039439487434752.svg?label=Discord&logo=discord&color=7289DA&labelColor=2C2F33)](https://discord.mod.io)
58
[![Master docs](https://img.shields.io/badge/docs-master-green.svg)](https://github.com/modio/modio-unity-v2/wiki)
69
[![Unity 3D](https://img.shields.io/badge/Unity-2018.4+-lightgrey.svg)](https://unity3d.com)
710

811
## Installation
9-
10-
### <a href="https://www.youtube.com/watch?v=pmECrkdzHzQ">Watch the video tutorial</a>
11-
<a href="https://www.youtube.com/watch?v=pmECrkdzHzQ"><img src="https://img.youtube.com/vi/pmECrkdzHzQ/0.jpg" alt="mod.io" width="420"/></a>
12+
Requires **Unity 2018.4** or later. Tested on Windows, and MacOS.
1213

1314
### Git Repository or .unitypackage
1415
You can import the plugin directly from the [Unity Asset Store](https://assetstore.unity.com/packages/tools/integration/mod-browser-manager-by-mod-io-138866), or by downloading the package directly from the [Releases page](https://github.com/modio/modio-unity/releases). If you have any previous versions of the plugin installed, it is highly recommended to delete them before importing a newer version.
@@ -20,9 +21,9 @@ Alternatively, you can download an archive of the code using GitHub's download f
2021
1. Set up your [game profile on mod.io](https://mod.io/games/add) (or our [private test environment](https://test.mod.io/games/add)) to get your game ID and API key.
2122
2. Add the plugin to your project using the installation instructions above.
2223
3. Ensure you dont have any conflicting libraries by going to Assets/Plugins/mod.io/ThirdParty to remove any libraries you may already have in your project (such as JsonNet).
23-
4. Restart Unity to ensure it recognises the new assembly definitions.
24+
4. Restart unity to ensure it recognises the new assembly definitions.
2425
5. Go to Tools > mod.io > Edit Settings to locate the config file.
25-
6. Select the config file and use the inspector to assign your game ID and API key in server settings (Make sure to deselect the config file before using playmode in the editor. A known Unity bug can cause the editor to crash in 2019-2021).
26+
6. Select the config file and use the inspector to assign your game ID and API key in server settings (Make sure to deselect the config file before using playmode in the editor. A known unity bug can cause the editor to crash in 2019-2021).
2627
7. Setup complete! Join us [on Discord](https://discord.mod.io) if you have any questions or need help.
2728

2829
## Setting up the Browser UI
@@ -40,23 +41,23 @@ In the current version of the plugin it is required that a user session is authe
4041

4142

4243
## Usage
43-
Below are a couple examples for some of the common usages of the plugin. Such as initialising, authenticating, enabling automatic downloads and installs, and getting a few mods from the mod.io server.
44+
below are a couple examples for some of the common usages of the plugin. Such as initialising, authenticating, enabling automatic downloads and installs, and getting a few mods from the mod.io server.
4445

4546
All of the methods required to use the plugin can be found in ModIOUnity.cs. If you prefer using async methods over callbacks you can alternatively use ModIOUnityAsync.cs to use an async variation of the same methods.
4647

47-
### Initialize the plugin
48+
### Initialise the plugin
4849
```javascript
49-
void async Example()
50+
async void Example()
5051
{
51-
Result result = await ModIOUnityAsync.InitializeForUserAsync("ExampleUser");
52+
Result result = await ModIOUnityAsync.InitializeForUser("ExampleUser");
5253

5354
if (result.Succeeded())
5455
{
55-
Debug.Log("Initialized plugin");
56+
Debug.Log("Initialised plugin");
5657
}
5758
else
5859
{
59-
Debug.Log("Failed to initialize plugin");
60+
Debug.Log("Failed to initialise plugin");
6061
{
6162
}
6263
```
@@ -96,7 +97,7 @@ void Example()
9697
}
9798

9899
// The following method will get invoked whenever an event concerning mod management occurs
99-
void ModManagementDelegate(ModManagementEventType eventType, ModId modId)
100+
void ModManagementDelegate(ModManagementEventType eventType, ModId modId, Result result)
100101
{
101102
Debug.Log("a mod management event of type " + eventType.ToString() + " has been invoked");
102103
}
@@ -105,7 +106,7 @@ void ModManagementDelegate(ModManagementEventType eventType, ModId modId)
105106
### Authenticate a user
106107
In the current version of the plugin it is required that a user session is authenticated in order to subscribe and download mods. You can accomplish this with an email address or through another third party service, such as Steam or Google. Below is an example of how to do this from an email address provided by the user. A security code will be sent to their email account and can be used to authenticate (The plugin will cache the session token to avoid having to re-authenticate every time they run the application).
107108
```javascript
108-
void async RequestEmailCode()
109+
async void RequestEmailCode()
109110
{
110111
Result result = await ModIOUnityAsync.RequestAuthenticationEmail("[email protected]");
111112

@@ -119,7 +120,7 @@ void async RequestEmailCode()
119120
}
120121
}
121122

122-
void async SubmitCode(string userSecurityCode)
123+
async void SubmitCode(string userSecurityCode)
123124
{
124125
Result result = await ModIOUnityAsync.SubmitEmailSecurityCode(userSecurityCode);
125126

@@ -136,7 +137,7 @@ void async SubmitCode(string userSecurityCode)
136137
137138
### Get Mod profiles from the mod.io server
138139
```javascript
139-
void async Example()
140+
async void Example()
140141
{
141142
// create a filter to retreive the first ten mods for your game
142143
SearchFilter filter = new SearchFilter();
@@ -147,7 +148,7 @@ void async Example()
147148

148149
if (response.result.Succeeded())
149150
{
150-
Debug.Log("ModPage has " + response.value.mods.Length + " mods");
151+
Debug.Log("ModPage has " + response.value.modProfiles.Length + " mods");
151152
}
152153
else
153154
{
@@ -156,7 +157,7 @@ void async Example()
156157
}
157158
```
158159
159-
## Submitting mods
160+
##Submitting mods
160161
You can also submit mods directly from the plugin. Refer to the documentation for methods such as ModIOUnity.CreateModProfile and ModIOUnity.UploadModfile.
161162
162163
Users can also submit mods directly from the mod.io website by going to your game profile page. Simply create an account and upload mods directly.
@@ -180,7 +181,7 @@ mod.io offers the same core functionality as Steamworks Workshop (1 click mod in
180181
A private white label option is available to license, if you want a fully featured mod-platform that you can control and host in-house. [Contact us](mailto:[email protected]?subject=Whitelabel) to discuss.
181182
182183
## Contributions Welcome
183-
Our Unity plugin is public and open source. Game developers are welcome to utilize it directly, to add support for mods in their games, or fork it for their games customized use.
184+
Our Unity plugin is public and open source. Game developers are welcome to utilize it directly, to add support for mods in their games, or fork it for their games customized use. Want to make changes to our plugin? Submit a pull request with your recommended changes to be reviewed.
184185
185186
## Other Repositories
186187
Our aim with [mod.io](https://mod.io), is to provide an [open modding API](https://docs.mod.io). You are welcome to [view, fork and contribute to our other codebases](https://github.com/modio) in use.

Runtime/Classes/CreationToken.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11

22
namespace ModIO
33
{
4+
/// <summary>
5+
/// This is used with creating new mod profiles. Using a token ensures you dont
6+
/// create duplicate profiles.
7+
/// </summary>
8+
/// <seealso cref="ModIOUnity.GenerateCreationToken"/>
9+
/// <seealso cref="ModIOUnityAsync.CreateModProfile"/>
10+
/// <seealso cref="ModIOUnity.CreateModProfile"/>
411
public class CreationToken
512
{
613
string creationTokenFileHash;

Runtime/Classes/ModProfileDetails.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ namespace ModIO
99
/// summary, otherwise the submission will be rejected (All fields except modId are optional if
1010
/// submitting this via EditModProfile)
1111
/// </summary>
12+
/// <seealso cref="ModIOUnity.CreateModProfile"/>
13+
/// <seealso cref="ModIOUnity.EditModProfile"/>
1214
public class ModProfileDetails
1315
{
1416
/// <summary>

Runtime/Classes/SearchFilter.cs

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ namespace ModIO
66
/// <summary>
77
/// Used to build a filter that is sent with requests for retrieving mods.
88
/// </summary>
9+
/// <seealso cref="ModIOUnity.GetMods"/>
10+
/// <seealso cref="ModIOUnityAsync.GetMods"/>
911
public class SearchFilter
1012
{
1113
bool hasPageIndexBeenSet = false;
1214
bool hasPageSizeBeenSet = false;
1315

1416
#region Endpoint Parameters
17+
// These are for internal use. Do not use
1518
internal string sortFieldName = string.Empty;
1619
internal bool isSortAscending = true;
1720
internal SortModsBy sortBy = SortModsBy.DateSubmitted;
@@ -20,39 +23,84 @@ public class SearchFilter
2023
internal List<string> searchPhrases = new List<string>();
2124
internal List<string> tags = new List<string>();
2225
#endregion
23-
26+
/// <summary>
27+
/// Adds a phrase into the filter to be used when filtering mods in a request.
28+
/// </summary>
29+
/// <param name="phrase">the string to be added to the filter</param>
2430
public void AddSearchPhrase(string phrase)
2531
{
2632
searchPhrases.Add(phrase);
2733
}
2834

35+
/// <summary>
36+
/// Adds a tag to be used in filtering mods for a request.
37+
/// </summary>
38+
/// <param name="tag">the tag to be added to the filter</param>
39+
/// <seealso cref="Tag"/>
40+
/// <seealso cref="TagCategory"/>
2941
public void AddTag(string tag)
3042
{
3143
tags.Add(tag);
3244
}
3345

46+
/// <summary>
47+
/// Determines what category mods should be sorted and returned by. eg if the category
48+
/// SortModsBy.Downloads was used, then the results would be returned by the number of
49+
/// downloads. Depending on the Ascending or Descending setting, it will start or end with
50+
/// mods that have the highest or lowest number of downloads.
51+
/// </summary>
52+
/// <param name="category">the category to sort the request</param>
53+
/// <seealso cref="SetToAscending"/>
3454
public void SortBy(SortModsBy category)
3555
{
3656
sortBy = category;
3757
}
3858

59+
/// <summary>
60+
/// Determines the order of the results being returned. eg should results be filtered from
61+
/// highest to lowest, or lowest to highest.
62+
/// </summary>
63+
/// <param name="isAscending"></param>
3964
public void SetToAscending(bool isAscending)
4065
{
4166
isSortAscending = isAscending;
4267
}
4368

69+
/// <summary>
70+
/// Sets the zero based index of the page. eg if there are 1,000 results based on the filter
71+
/// settings provided, and the page size is 100. Setting this to 1 will return the mods from
72+
/// 100-200. Whereas setting this to 0 will return the first 100 results.
73+
/// </summary>
74+
/// <param name="pageIndex"></param>
75+
/// <seealso cref="SetPageSize"/>
4476
public void SetPageIndex(int pageIndex)
4577
{
4678
this.pageIndex = pageIndex;
4779
hasPageIndexBeenSet = true;
4880
}
4981

82+
/// <summary>
83+
/// Sets the maximum page size of the request. eg if there are 50 results and the index is
84+
/// set to 0. If the page size is set to 10 you will receive the first 10 results. If the
85+
/// page size is set to 100 you will only receive the total 50 results, because there are
86+
/// no more to be got.
87+
/// </summary>
88+
/// <param name="pageSize"></param>
89+
/// <seealso cref="SetPageIndex"/>
5090
public void SetPageSize(int pageSize)
5191
{
5292
this.pageSize = pageSize;
5393
hasPageSizeBeenSet = true;
5494
}
5595

96+
/// <summary>
97+
/// You can use this method to check if a search filter is setup correctly before using it
98+
/// in a GetMods request.
99+
/// </summary>
100+
/// <param name="result"></param>
101+
/// <returns>true if the filter is valid</returns>
102+
/// <seealso cref="ModIOUnity.GetMods"/>
103+
/// <seealso cref="ModIOUnityAsync.GetMods"/>
56104
public bool IsSearchFilterValid(out Result result)
57105
{
58106
bool paginationSet = hasPageIndexBeenSet && hasPageSizeBeenSet;
@@ -62,14 +110,13 @@ public bool IsSearchFilterValid(out Result result)
62110
// TODO Check if tags are correct? Or will they just get ignored?
63111
// ^ Perhaps log a warning if non-fatal
64112

65-
66113
if(!paginationSet)
67114
{
68115
result = ResultBuilder.Create(ResultCode.InvalidParameter_PaginationParams);
69116
Logger.Log(
70117
LogLevel.Error,
71118
"The pagination parameters haven't been set for this filter. Make sure to "
72-
+ "use SetPage(int) and SetPageSize(int) before using a filter.");
119+
+ "use SetPageIndex(int) and SetPageSize(int) before using a filter.");
73120
}
74121
else
75122
{

Runtime/Enums/LogLevel.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
namespace ModIO
22
{
3+
/// <summary>
4+
/// The logging level of the plugin. Used in BuildSettings to determine which log messages to
5+
/// ignore or display.
6+
/// </summary>
37
public enum LogLevel
48
{
59
None = -1,

Runtime/Enums/ModStatus.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
{
33
public enum ModStatus
44
{
5-
Accepted,
6-
NotAccepted,
7-
Deleted
5+
Accepted = 0,
6+
NotAccepted = 1,
7+
Deleted = 3
88
}
99
}

Runtime/Enums/SortModsBy.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11

22
namespace ModIO
33
{
4+
/// <summary>
5+
/// Category to be used in the SearchFilter for determining how mods should be filtered in a
6+
/// request.
7+
/// </summary>
8+
/// <seealso cref="SearchFilter"/>
9+
/// <seealso cref="ModIOUnity.GetMods"/>
10+
/// <seealso cref="ModIOUnityAsync.GetMods"/>
411
public enum SortModsBy
512
{
613
Name,

Runtime/Enums/SubscribedModStatus.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
namespace ModIO
22
{
3+
/// <summary>
4+
/// The current state of a subscribed mod. Useful for checking whether or not a mod has been
5+
/// installed yet or if there was a problem trying to download/install it.
6+
/// </summary>
7+
/// <seealso cref="SubscribedMod"/>
38
public enum SubscribedModStatus
49
{
510
Installed,

Runtime/Enums/UserPortal.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
namespace ModIO
22
{
3-
/// <summary>Values representing the valid User Portals that mod.io works with.</summary>
3+
/// <summary>
4+
/// Values representing the valid User Portals that mod.io works with.
5+
/// Used when setting up BuildSettings.
6+
/// </summary>
7+
/// <seealso cref="BuildSettings"/>
48
public enum UserPortal
59
{
610
None = 0,

0 commit comments

Comments
 (0)