Skip to content

Develop #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Jul 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d411815
Minor fixes to UIService and code cleaning
nievesj Jun 29, 2018
f4e45be
Removing LeanTween in favor of DOTween #44.
nievesj Jun 30, 2018
83b6b99
Cleaning up uiservice
nievesj Jun 30, 2018
4cb8118
minor fix, adding comments
nievesj Jun 30, 2018
383e01e
Adding UnityTaskExtensions. 2 simple extensions that provide a callba…
nievesj Jul 1, 2018
2472b53
Updating Async tools from https://github.com/svermeulen/Unity3dAsyncA…
nievesj Jul 2, 2018
dcee571
Improving task creation on UnityTaskExtensions.
nievesj Jul 2, 2018
d037fcf
Improving Asset Service.
nievesj Jul 2, 2018
d5add6b
Changing OnGameStart Subject injection to IObservable.
nievesj Jul 3, 2018
eb3b108
A letter.
nievesj Jul 3, 2018
3b4c31e
Minor fixes
nievesj Jul 3, 2018
5634493
Adding option bypass loading assets, now if an asset is included in t…
nievesj Jul 3, 2018
a386c86
Adding new service that serves as a wrapper for the UnityEngine.Socia…
nievesj Jul 6, 2018
4c2d647
Minor fix on game configuration
nievesj Jul 6, 2018
35cfdaa
Adding PersistentDataService, this helps serialize and save data loca…
nievesj Jul 7, 2018
f94f6b8
Comments. Improving Persistent Data Service.
nievesj Jul 7, 2018
84086e8
Renaming a menu.
nievesj Jul 7, 2018
22cfb72
Adding a new menu item
nievesj Jul 7, 2018
a625f69
Improving asset bundle simulation mode, added new method to load mult…
nievesj Jul 7, 2018
da08060
Forgot to remove obsolete method.
nievesj Jul 7, 2018
68217eb
meta files
nievesj Jul 8, 2018
7b3a298
Updating Zenject to 6.1.1
nievesj Jul 8, 2018
07021cf
Resolving conflicts.
nievesj Jul 8, 2018
bc0954e
Added assembly definition for UniRx so I can enable Zenject's UniRx s…
nievesj Jul 8, 2018
6ae008f
Removing unnecessary Subjects from UI Service and ui elements. Added …
nievesj Jul 8, 2018
fe33417
Added IProgress and CancellationToken parameters to all async tasks r…
nievesj Jul 9, 2018
866b636
Removing Update service and level loader service. Cleaning up.
nievesj Jul 9, 2018
58e6360
Umm... forgot these...
nievesj Jul 9, 2018
87a34e8
Improving UIService and ui elements. Converted all observables from U…
nievesj Jul 9, 2018
fc3ad70
Updating asset bundle browser: https://github.com/Unity-Technologies/…
nievesj Jul 9, 2018
a6e231c
Cleanup
nievesj Jul 10, 2018
9efdb31
Updating UniRx to 6.0.0 https://github.com/neuecc/UniRx/releases/tag/…
nievesj Jul 10, 2018
8cb8abe
Reverted Zenject to 5.5.1 because it was causing IL2CPP errors when b…
nievesj Jul 11, 2018
dad7d59
cleanup
nievesj Jul 11, 2018
e3e6b4d
Removing AsyncAwaitUtil because UniRx.Async has similar features with…
nievesj Jul 12, 2018
821c5b4
Improving audio service. Cleanup.
nievesj Jul 13, 2018
a122224
Big cleanup. Targeting .net Standard 2.0 and C# 7. This means the pro…
nievesj Jul 14, 2018
33ae06c
Minor tweaks to level and screen blocks. Added a Destroy extension fo…
nievesj Jul 15, 2018
79872cf
Updating Readme
nievesj Jul 16, 2018
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
3 changes: 2 additions & 1 deletion CoreFramework-ASM.asmdef
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "CoreFramework-ASM",
"references": [
"Zenject"
"Zenject",
"UniRx"
],
"optionalUnityReferences": [],
"includePlatforms": [],
Expand Down
32 changes: 18 additions & 14 deletions Editor/ClearCacheMenuItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
/// </summary>
public class ClearCacheMenuItem
{
[MenuItem("_Core / Clear Asset Bundle Cache")]
private static void CreateRedBlueGameObject()
[MenuItem("Core Framework / Clear Asset Bundle Cache")]
private static void ClearAssetBundleCache()
{
//Get all cache paths... in Unity's unique way....
var cachePaths = new List<string>();
Expand All @@ -29,39 +29,43 @@ private static void CreateRedBlueGameObject()

if (cachePaths.Count < 1)
Debug.Log(("Cache was empty.").Colored(Colors.Yellow));
}

//Delete any cached .manifest files
[MenuItem("Core Framework / Delete Persistent Data Directory (Also deletes any saved data files)")]
private static void DeletePersistentData()
{
//Delete Application.persistentDataPath
Directory.Delete(Application.persistentDataPath, true);
Debug.Log(("Clearing persistent data: Directory " + Application.persistentDataPath + " deleted.").Colored(Colors.Yellow));
Debug.Log(("Deleting persistent data directory " + Application.persistentDataPath).Colored(Colors.Yellow));
}

[MenuItem("_Core / Enable Simulate Asset Bundles")]
[MenuItem("Core Framework / Enable Simulate Asset Bundles")]
private static void GetEnableCachedInfo()
{
CreateRedBlueGameObject();
ClearAssetBundleCache();

EditorPreferences.EDITORPREF_SIMULATE_ASSET_BUNDLES = true;
EditorPreferences.EditorprefSimulateAssetBundles = true;
Debug.Log(("Enabled asset bundle simulation mode.").Colored(Colors.Yellow));
}

[MenuItem("_Core / Enable Simulate Asset Bundles", true)]
[MenuItem("Core Framework / Enable Simulate Asset Bundles", true)]
private static bool GetEnableCachedInfoVal()
{
return !EditorPreferences.EDITORPREF_SIMULATE_ASSET_BUNDLES ? true : false;
return !EditorPreferences.EditorprefSimulateAssetBundles ? true : false;
}

[MenuItem("_Core / Disable Simulate Asset Bundles")]
[MenuItem("Core Framework / Disable Simulate Asset Bundles")]
private static void GetDisableCachedInfo()
{
CreateRedBlueGameObject();
ClearAssetBundleCache();

EditorPreferences.EDITORPREF_SIMULATE_ASSET_BUNDLES = false;
EditorPreferences.EditorprefSimulateAssetBundles = false;
Debug.Log(("Disabled asset bundle simulation mode.").Colored(Colors.Yellow));
}

[MenuItem("_Core / Disable Simulate Asset Bundles", true)]
[MenuItem("Core Framework / Disable Simulate Asset Bundles", true)]
private static bool GetDisableCachedInfoVal()
{
return EditorPreferences.EDITORPREF_SIMULATE_ASSET_BUNDLES ? true : false;
return EditorPreferences.EditorprefSimulateAssetBundles ? true : false;
}
}
6 changes: 3 additions & 3 deletions Editor/EditorStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ public class Startup
{
static Startup()
{
if (EditorPreferences.EDITORPREF_FIRST_TIME_USE)
if (EditorPreferences.EditorprefFirstTimeUse)
{
Debug.Log("First time use. Enabling asset bundle simulation mode.".Colored(Colors.Yellow));

EditorPreferences.EDITORPREF_SIMULATE_ASSET_BUNDLES = true;
EditorPreferences.EDITORPREF_FIRST_TIME_USE = false;
EditorPreferences.EditorprefSimulateAssetBundles = true;
EditorPreferences.EditorprefFirstTimeUse = false;
}
}
}
Expand Down
49 changes: 24 additions & 25 deletions Editor/GameConfigurationEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@ namespace Core.Services
[CustomEditor(typeof(GameConfiguration))]
public class GameConfigurationEditor : Editor
{
private ReorderableList services;
private GameConfiguration gameConfiguration;
private ReorderableList _services;
private GameConfiguration _gameConfiguration;

public override void OnInspectorGUI()
{
gameConfiguration = target as GameConfiguration;

gameConfiguration.disableLogging = EditorGUILayout.ToggleLeft("Disable Debug.Log?", gameConfiguration.disableLogging);
_gameConfiguration = target as GameConfiguration;
_gameConfiguration.DisableLogging = EditorGUILayout.ToggleLeft("Disable Debug.Log?", _gameConfiguration.DisableLogging);

GUILayout.Space(10);
serializedObject.Update();
services.DoLayoutList();
_services.DoLayoutList();
serializedObject.ApplyModifiedProperties();
}

Expand All @@ -31,19 +30,19 @@ private void OnEnable()
Color contentColor = GUI.contentColor;
float line = EditorGUIUtility.singleLineHeight;
SerializedProperty property = serializedObject.FindProperty("services");
services = new ReorderableList(serializedObject, property);
services.showDefaultBackground = true;
services.elementHeight = line + 6;
_services = new ReorderableList(serializedObject, property);
_services.showDefaultBackground = true;
_services.elementHeight = line + 6;

services.drawHeaderCallback = (rect) =>
_services.drawHeaderCallback = (rect) =>
{
EditorGUI.LabelField(rect, "Core Framework Services");
};

services.drawElementCallback = (Rect rect, int index, bool active, bool focused) =>
_services.drawElementCallback = (Rect rect, int index, bool active, bool focused) =>
{
float width = rect.width - 22;
SerializedProperty element = services.serializedProperty.GetArrayElementAtIndex(index);
SerializedProperty element = _services.serializedProperty.GetArrayElementAtIndex(index);

if (GUI.Button(new Rect(rect.x + rect.width - 20, rect.y + 4, 18, line), EditorGUIUtility.IconContent("_Popup").image, GUIStyle.none))
{
Expand All @@ -55,16 +54,16 @@ private void OnEnable()

menu.AddItem(new GUIContent("Remove"), false, delegate ()
{
if (!gameConfiguration.services[index])
if (!_gameConfiguration.services[index])
{
gameConfiguration.services.RemoveAt(index);
EditorUtility.SetDirty(gameConfiguration);
_gameConfiguration.services.RemoveAt(index);
EditorUtility.SetDirty(_gameConfiguration);
}
else if (EditorUtility.DisplayDialog("Remove " + ObjectNames.NicifyVariableName(gameConfiguration.services[index].name) + "?", "Are you sure you want to remove this service? This will delete the ScriptableObject and can't be undone.", "Yes", "No"))
else if (EditorUtility.DisplayDialog("Remove " + ObjectNames.NicifyVariableName(_gameConfiguration.services[index].name) + "?", "Are you sure you want to remove this service? This will delete the ScriptableObject and can't be undone.", "Yes", "No"))
{
AssetDatabase.DeleteAsset(AssetDatabase.GetAssetOrScenePath(element.objectReferenceValue));
gameConfiguration.services.RemoveAt(index);
EditorUtility.SetDirty(gameConfiguration);
_gameConfiguration.services.RemoveAt(index);
EditorUtility.SetDirty(_gameConfiguration);
}
});

Expand All @@ -74,7 +73,7 @@ private void OnEnable()
EditorGUI.PropertyField(new Rect(rect.x, rect.y + 2, width, line), element, GUIContent.none);
};

services.onAddCallback = (list) =>
_services.onAddCallback = (list) =>
{
Type[] allServiceTypes = GetAllServiceTypes();
GenericMenu servicesMenu = new GenericMenu();
Expand All @@ -90,16 +89,16 @@ private void OnEnable()
if (typ.Name == styp.Name + "Config" || typ.Name == styp.Name + "Configuration")
{
serializedObject.ApplyModifiedProperties();
object thing = ScriptableObject.CreateInstance(typ);
if (thing == null || (thing as ServiceConfiguration) == null) return;
object so = ScriptableObject.CreateInstance(typ);
if (so == null || (so as ServiceConfiguration) == null) return;
serializedObject.ApplyModifiedProperties();
string path = AssetDatabase.GetAssetOrScenePath(serializedObject.targetObject);
path = Path.GetDirectoryName(path) + Path.DirectorySeparatorChar + styp.Name + ".asset";
AssetDatabase.CreateAsset(thing as ServiceConfiguration, path);
if (thing != null)
AssetDatabase.CreateAsset(so as ServiceConfiguration, path);
if (so != null)
{
gameConfiguration.services.Add(thing as ServiceConfiguration);
EditorUtility.SetDirty(gameConfiguration);
_gameConfiguration.services.Add(so as ServiceConfiguration);
EditorUtility.SetDirty(_gameConfiguration);
}
return;
}
Expand Down
115 changes: 0 additions & 115 deletions Editor/LevelLoaderServiceConfigurationEditor.cs

This file was deleted.

4 changes: 2 additions & 2 deletions Editor/Preferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private static void CustomPreferencesGUI()
{
if (!prefsLoaded)
{
simulateAssetBundles = EditorPreferences.EDITORPREF_SIMULATE_ASSET_BUNDLES;
simulateAssetBundles = EditorPreferences.EditorprefSimulateAssetBundles;
prefsLoaded = true;
}

Expand All @@ -22,7 +22,7 @@ private static void CustomPreferencesGUI()

if (GUI.changed)
{
EditorPreferences.EDITORPREF_SIMULATE_ASSET_BUNDLES = simulateAssetBundles;
EditorPreferences.EditorprefSimulateAssetBundles = simulateAssetBundles;
}

EditorUITools.HorizontalLine();
Expand Down
29 changes: 19 additions & 10 deletions Extensions/ObservableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class ObservableExtensions
/// <returns></returns>
public static IObservable<UnityEngine.Object> ToObservable(this UnityEngine.AssetBundleRequest asyncOperation)
{
if (asyncOperation == null) throw new ArgumentNullException("asyncOperation");
if (asyncOperation == null) throw new ArgumentNullException(nameof(asyncOperation));
return Observable.FromCoroutine<UnityEngine.Object>((observer, cancellationToken) => RunAssetBundleRequestOperation(asyncOperation, observer, cancellationToken));
}

Expand All @@ -29,35 +29,44 @@ private static IEnumerator RunAssetBundleRequestOperation(UnityEngine.AssetBundl
}
}

/// <summary>
/// Converts a Task to an Observable, runs on main thread.
/// </summary>
/// <param name="task"></param>
/// <returns></returns>
public static IObservable<Unit> TaskToObservable(this Task task)
{
return Observable.Create<Unit>(
(observer) =>
{
Func<Task> runTask = async () =>
task.Run(_ =>
{
await task;
observer.OnNext(new Unit());
observer.OnCompleted();
};
runTask();
});

return Disposable.Empty;
}
);
}

/// <summary>
/// Converts a Task<T/> to an Observable, runs on main thread.
/// </summary>
/// <param name="task"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static IObservable<T> TaskToObservable<T>(this Task<T> task) where T : UnityEngine.Object
{
return Observable.Create<T>(
(observer) =>
{
Func<Task> runTask = async () =>
task.Run(x =>
{
var val = await task;
observer.OnNext(val);
observer.OnNext(x);
observer.OnCompleted();
};
runTask();
});

return Disposable.Empty;
}
);
Expand Down
Loading