Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ebukaracer committed Dec 21, 2022
0 parents commit b946507
Show file tree
Hide file tree
Showing 441 changed files with 60,633 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
72 changes: 72 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# 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/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/

# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/[Mm]emoryCaptures/

# Recordings can get excessive in size
/[Rr]ecordings/

# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*

# Autogenerated Jetbrains Rider plugin
/[Aa]ssets/Plugins/Editor/JetBrains*

# Visual Studio cache directory
.vs/

# Gradle cache directory
.gradle/

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db

# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta

# Unity3D generated file on crash reports
sysinfo.txt

# Builds
*.apk
*.aab
*.unitypackage
*.app

# Crashlytics generated file
crashlytics-build.properties

# Packed Addressables
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*

# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*
6 changes: 6 additions & 0 deletions .vsconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedGame"
]
}
8 changes: 8 additions & 0 deletions Assets/Save System.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/Save System/Editor.meta

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

90 changes: 90 additions & 0 deletions Assets/Save System/Editor/SaveSystemUtilityWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#if UNITY_EDITOR
using System;
using UnityEditor;
using UnityEngine;

namespace Racer.SaveSystem
{
internal class SaveSystemUtilityWindow : EditorWindow
{
private const int Width = 400;

public static bool OverwriteSaveFile { get; private set; }

[MenuItem("Save_System/Save Utility Window")]
public static void DisplayWindow()
{
OverwriteSaveFile = EditorPrefs.GetBool("SSUW_owsf");

var window = GetWindow<SaveSystemUtilityWindow>();

window.titleContent = new GUIContent("Save Utility Window");

// Limit size of the window, non re-sizable
window.minSize = new Vector2(Width, Width);
window.maxSize = new Vector2(Width, Width);
}

/// <value>
/// Returns a path from <see cref="SavePaths"/> class.
/// </value>
private static string PathTemplate
{
get
{
var path = SavePaths.SaveDirectoryPath;

#if UNITY_2021_1_OR_NEWER
var shortenedPath = path[path.IndexOf("Assets", StringComparison.Ordinal)..];
#else
var shortenedPath = path.Substring(path.IndexOf("Assets", StringComparison.Ordinal));
#endif
return string.IsNullOrEmpty(shortenedPath) ? path : shortenedPath;
}
}

private void OnGUI()
{
#if UNITY_2019_1_OR_NEWER
EditorGUILayout.Space(10);
#else
EditorGUILayout.Space();
#endif
EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(Width));

EditorGUILayout.HelpBox($"A default [{SavePaths.SaveFileName}] would be created at the following directory: [{PathTemplate}].\n" +
$" The default settings such as the save-file path or save-file name can be modified via: [{nameof(SavePaths)}.cs]", MessageType.Info);

EditorGUILayout.EndHorizontal();

#if UNITY_2019_1_OR_NEWER
EditorGUILayout.Space(5);
#else
EditorGUILayout.Space();
#endif
GUILayout.Label("Base Settings", EditorStyles.boldLabel);

if (GUILayout.Button(new GUIContent("Create New Save File", "Creates a new save file."), GUILayout.MaxWidth(Width)))
SaveSystem.CreateSaveDirAndFile(OverwriteSaveFile);

if (GUILayout.Button(new GUIContent("Delete Save File", "Deletes the created save file"), GUILayout.MaxWidth(Width)))
SaveSystem.DeleteSaveFile();

#if UNITY_2019_1_OR_NEWER
EditorGUILayout.Space(15);
#else
EditorGUILayout.Space();
#endif
GUILayout.Label("Other Settings", EditorStyles.boldLabel);

EditorGUILayout.HelpBox($"Toggling [overwrite] would overwrite the previously created save-file during creation.", MessageType.Info);

OverwriteSaveFile = EditorGUILayout.Toggle("Overwrite Save file", OverwriteSaveFile, GUILayout.MaxWidth(Width));
}
private void OnDestroy()
{
EditorPrefs.SetBool("SSUW_owsf", OverwriteSaveFile);
}
}
}
#endif
11 changes: 11 additions & 0 deletions Assets/Save System/Editor/SaveSystemUtilityWindow.cs.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/Save System/Prefabs.meta

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

46 changes: 46 additions & 0 deletions Assets/Save System/Prefabs/SavePoint.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &7195924799128453129
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7195924799128453131}
- component: {fileID: 7195924799128453140}
m_Layer: 0
m_Name: SavePoint
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7195924799128453131
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7195924799128453129}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &7195924799128453140
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7195924799128453129}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7cc89746f03101244b8563265af29b0d, type: 3}
m_Name:
m_EditorClassIdentifier:
7 changes: 7 additions & 0 deletions Assets/Save System/Prefabs/SavePoint.prefab.meta

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

16 changes: 16 additions & 0 deletions Assets/Save System/SaveSystem.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "SaveSystem",
"rootNamespace": "Racer.SaveSystem",
"references": [
"GUID:821b0ee03ff72524ebad25077d12a3c7"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions Assets/Save System/SaveSystem.asmdef.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/Save System/Saves.meta

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

9 changes: 9 additions & 0 deletions Assets/Save System/Saves/Save.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"KeyValues": {
"Username": "Racer",
"Difficulty": 0,
"BestTime.4X4.Num_0": 375.0573,
"BestTime.4X4.Str_0": "6m:15s",
"Cash": 3
}
}
7 changes: 7 additions & 0 deletions Assets/Save System/Saves/Save.txt.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/Save System/_Scripts.meta

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

42 changes: 42 additions & 0 deletions Assets/Save System/_Scripts/CustomConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;

namespace Racer.SaveSystem
{
/// <summary>
/// Efficiently converts data types to their target type.
/// The tokens are types <see cref="SaveSystem"/> can handle.
/// </summary>
internal class CustomConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return typeof(object) == objectType;
}

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var jToken = JToken.ReadFrom(reader);

switch (reader.TokenType)
{
case JsonToken.Integer:
return jToken.Value<int>();
case JsonToken.String:
return jToken.Value<string>();
case JsonToken.Float:
return jToken.Value<float>();
case JsonToken.Boolean:
return jToken.Value<bool>();
default:
throw new ArgumentException($"Unknown JsonToken: '{reader.TokenType}'.");
}
}

public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
serializer.Serialize(writer, value.ToString());
}
}
}
11 changes: 11 additions & 0 deletions Assets/Save System/_Scripts/CustomConverter.cs.meta

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

Loading

0 comments on commit b946507

Please sign in to comment.