Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Created by https://www.toptal.com/developers/gitignore/api/unity
# Edit at https://www.toptal.com/developers/gitignore?templates=unity

### Unity ###
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
Expand Down Expand Up @@ -74,5 +71,6 @@ crashlytics-build.properties
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*

# End of https://www.toptal.com/developers/gitignore/api/unity

# Additional Rivet items
**/.DS_Store
/ProjectSettings
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"visualstudiotoolsforunity.vstuc"
]
}
10 changes: 10 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Unity",
"type": "vstuc",
"request": "attach"
}
]
}
60 changes: 60 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"files.exclude": {
"**/.DS_Store": true,
"**/.git": true,
"**/.vs": true,
"**/.gitmodules": true,
"**/.vsconfig": true,
"**/*.booproj": true,
"**/*.pidb": true,
"**/*.suo": true,
"**/*.user": true,
"**/*.userprefs": true,
"**/*.unityproj": true,
"**/*.dll": true,
"**/*.exe": true,
"**/*.pdf": true,
"**/*.mid": true,
"**/*.midi": true,
"**/*.wav": true,
"**/*.gif": true,
"**/*.ico": true,
"**/*.jpg": true,
"**/*.jpeg": true,
"**/*.png": true,
"**/*.psd": true,
"**/*.tga": true,
"**/*.tif": true,
"**/*.tiff": true,
"**/*.3ds": true,
"**/*.3DS": true,
"**/*.fbx": true,
"**/*.FBX": true,
"**/*.lxo": true,
"**/*.LXO": true,
"**/*.ma": true,
"**/*.MA": true,
"**/*.obj": true,
"**/*.OBJ": true,
"**/*.asset": true,
"**/*.cubemap": true,
"**/*.flare": true,
"**/*.mat": true,
"**/*.meta": true,
"**/*.prefab": true,
"**/*.unity": true,
"build/": true,
"Build/": true,
"Library/": true,
"library/": true,
"obj/": true,
"Obj/": true,
"Logs/": true,
"logs/": true,
"ProjectSettings/": true,
"UserSettings/": true,
"temp/": true,
"Temp/": true
},
"dotnet.defaultSolution": "plugin-unity.sln"
}
8 changes: 8 additions & 0 deletions Assets/Rivet.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions Assets/Rivet/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# MARK: Runner
FROM ubuntu:22.04
WORKDIR /app

# Install necessary libraries for Unity
RUN apt-get update && apt-get install -y \
ca-certificates \
&& update-ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& useradd -ms /bin/bash rivet

# Copy the precompiled Unity server files
COPY ./Builds/Game /app/Game
# COPY ./Builds/Game_BurstDebugInformation_DoNotShip /app/Game_BurstDebugInformation_DoNotShip
# COPY ./Builds/Game_Data /app/Game_Data
# COPY ./Builds/UnityPlayer.so /app/UnityPlayer.so

# Change to user rivet
USER rivet

ENV UNITY_SERVER=1

# Run the server
ENTRYPOINT ["./Game", "-batchmode", "-nographics"]
7 changes: 7 additions & 0 deletions Assets/Rivet/Dockerfile.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Rivet/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions Assets/Rivet/Editor/BuildPipeline.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;

public class BuildScript : IPreprocessBuildWithReport, IPostprocessBuildWithReport
{
public int callbackOrder { get { return 0; } }

public void OnPreprocessBuild(BuildReport report)
{
// Create the asset file before the build
RivetSettings data = ScriptableObject.CreateInstance<RivetSettings>();
// data.SomeData = "Some data from the plugin";
AssetDatabase.CreateAsset(data, "Assets/rivet_export.asset");
AssetDatabase.SaveAssets();
}

public void OnPostprocessBuild(BuildReport report)
{
// Delete the asset file after the build
AssetDatabase.DeleteAsset("Assets/rivet_export.asset");
}
}
11 changes: 11 additions & 0 deletions Assets/Rivet/Editor/BuildPipeline.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions Assets/Rivet/Editor/CoroutineUtility.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using UnityEngine;
using System.Collections;

public class CoroutineUtility : MonoBehaviour
{
public static CoroutineUtility instance;

private void Awake()
{
if (instance == null)
{
instance = this;
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
}
}

public Coroutine StartGlobalCoroutine(IEnumerator coroutine)
{
return StartCoroutine(coroutine);
}
}
11 changes: 11 additions & 0 deletions Assets/Rivet/Editor/CoroutineUtility.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions Assets/Rivet/Editor/EditorCoroutine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections;
using UnityEditor;

public class EditorCoroutine
{
public static EditorCoroutine Start(IEnumerator routine)
{
EditorCoroutine coroutine = new EditorCoroutine(routine);
coroutine.Start();
return coroutine;
}

readonly IEnumerator routine;
EditorCoroutine(IEnumerator routine)
{
this.routine = routine;
}

void Start()
{
EditorApplication.update += Update;
}
public void Stop()
{
EditorApplication.update -= Update;
}

void Update()
{
if (!routine.MoveNext())
{
Stop();
}
}
}
11 changes: 11 additions & 0 deletions Assets/Rivet/Editor/EditorCoroutine.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 98 additions & 0 deletions Assets/Rivet/Editor/Result.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;

// https://josef.codes/my-take-on-the-result-class-in-c-sharp/
public abstract class Result
{
public bool Success { get; protected set; }
public bool Failure => !Success;
}

public abstract class Result<T> : Result
{
private T _data;

protected Result(T data)
{
Data = data;
}

public T Data
{
get => Success ? _data : throw new Exception($"You can't access .{nameof(Data)} when .{nameof(Success)} is false");
set => _data = value;
}
}

public class SuccessResult : Result
{
public SuccessResult()
{
Success = true;
}
}

public class SuccessResult<T> : Result<T>
{
public SuccessResult(T data) : base(data)
{
Success = true;
}
}

public class ErrorResult : Result, IErrorResult
{
public ErrorResult(string message) : this(message, Array.Empty<Error>())
{
}

public ErrorResult(string message, IReadOnlyCollection<Error> errors)
{
Message = message;
Success = false;
Errors = errors ?? Array.Empty<Error>();
}

public string Message { get; }
public IReadOnlyCollection<Error> Errors { get; }
}

public class ErrorResult<T> : Result<T>, IErrorResult
{
public ErrorResult(string message) : this(message, Array.Empty<Error>())
{
}

public ErrorResult(string message, IReadOnlyCollection<Error> errors) : base(default)
{
Message = message;
Success = false;
Errors = errors ?? Array.Empty<Error>();
}

public string Message { get; set; }
public IReadOnlyCollection<Error> Errors { get; }
}

public class Error
{
public Error(string details) : this(null, details)
{

}

public Error(string code, string details)
{
Code = code;
Details = details;
}

public string Code { get; }
public string Details { get; }
}

internal interface IErrorResult
{
string Message { get; }
IReadOnlyCollection<Error> Errors { get; }
}
11 changes: 11 additions & 0 deletions Assets/Rivet/Editor/Result.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading