Skip to content

Commit 5a937e1

Browse files
committed
wip of the asset loader
1 parent abd6cc4 commit 5a937e1

24 files changed

+180
-0
lines changed

.gitignore

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# =============== #
2+
# Unity generated #
3+
# =============== #
4+
[Tt]emp/
5+
[Oo]bj/
6+
[Bb]uild
7+
[Ll]ibrary/
8+
sysinfo.txt
9+
.app
10+
11+
# ===================================== #
12+
# Visual Studio / MonoDevelop generated #
13+
# ===================================== #
14+
[Ee]xported[Oo]bj/
15+
*.userprefs
16+
*.csproj
17+
*.csproj.meta
18+
*.pidb
19+
*.suo
20+
*.sln*
21+
*.user
22+
*.unityproj
23+
*.booproj
24+
25+
# ============ #
26+
# OS generated #
27+
# ============ #
28+
.DS_Store*
29+
._*
30+
.Spotlight-V100
31+
.Trashes
32+
*Icon?
33+
*Icon?.meta
34+
ehthumbs.db
35+
[Tt]humbs.db
36+
.zip
37+
*.zip
38+
39+
# ========== #
40+
# Plugins #
41+
# ========== #
42+
UnityVS/
43+
*UnityVS.meta
44+
BIU/
45+
BIU.meta
46+
AutoSaver/
47+
AutoSaver.meta
48+
49+
# ======= #
50+
# Other #
51+
# ======= #
52+
out/
53+
logs/
54+
build-process/

Assets/UnityLoader.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/UnityLoader/Scripts.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using System.Collections;
2+
3+
public interface IAssetLoader
4+
{
5+
IEnumerator LoadAssetsCo();
6+
void AssetsLoaded();
7+
}

Assets/UnityLoader/Scripts/IAssetLoader.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
using UnityEngine;
2+
using System.Collections.Generic;
3+
4+
public static class UnityLoader
5+
{
6+
private static int _totalSteps;
7+
private static int _currentStep;
8+
9+
private static List<LoaderStep> _loaders = new List<LoaderStep>();
10+
11+
private static GameObject _helper;
12+
13+
private struct LoaderStep
14+
{
15+
public IAssetLoader loader;
16+
public int additionalSteps;
17+
18+
public LoaderStep(IAssetLoader loader, int additionalSteps)
19+
{
20+
this.loader = loader;
21+
this.additionalSteps = additionalSteps;
22+
}
23+
}
24+
25+
public static float progress
26+
{
27+
get { return (float)_currentStep / _totalSteps; }
28+
}
29+
30+
public static void RegisterObject(GameObject objToRegister, int additionalSteps = 0)
31+
{
32+
RegisterObject(objToRegister.GetComponent<IAssetLoader>(), additionalSteps);
33+
}
34+
35+
public static void RegisterObject(IAssetLoader loaderToRegister, int additionalSteps = 0)
36+
{
37+
if (loaderToRegister != null)
38+
{
39+
40+
_loaders.Add(new LoaderStep(loaderToRegister, additionalSteps));
41+
}
42+
}
43+
44+
public static void RegisterObjectDeep(GameObject objToRegister)
45+
{
46+
IAssetLoader[] loaders = objToRegister.GetComponentsInChildren<IAssetLoader>(true);
47+
48+
for (int i = 0; i < loaders.Length; i++)
49+
{
50+
RegisterObject(loaders[i]);
51+
}
52+
}
53+
54+
public static void StartLoading(System.Action onLoadComplete)
55+
{
56+
_totalSteps = _loaders.Count;
57+
58+
for (int i = 0; i < _loaders.Count; i++)
59+
{
60+
_totalSteps += _loaders[i].additionalSteps;
61+
}
62+
63+
64+
}
65+
66+
public static void CancelLoading()
67+
{
68+
69+
}
70+
71+
public static void IncrementLoadStep()
72+
{
73+
_currentStep++;
74+
}
75+
}

Assets/UnityLoader/Scripts/UnityLoader.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ProjectSettings/AudioManager.asset

4.04 KB
Binary file not shown.
4.01 KB
Binary file not shown.

ProjectSettings/DynamicsManager.asset

4.18 KB
Binary file not shown.
4.01 KB
Binary file not shown.

ProjectSettings/EditorSettings.asset

4.11 KB
Binary file not shown.
4.29 KB
Binary file not shown.

ProjectSettings/InputManager.asset

5.39 KB
Binary file not shown.

ProjectSettings/NavMeshAreas.asset

4.28 KB
Binary file not shown.

ProjectSettings/NetworkManager.asset

4.02 KB
Binary file not shown.
4.26 KB
Binary file not shown.

ProjectSettings/ProjectSettings.asset

43 KB
Binary file not shown.

ProjectSettings/ProjectVersion.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
m_EditorVersion: 5.4.0f3
2+
m_StandardAssetsVersion: 0

ProjectSettings/QualitySettings.asset

4.89 KB
Binary file not shown.

ProjectSettings/TagManager.asset

4.21 KB
Binary file not shown.

ProjectSettings/TimeManager.asset

4.02 KB
Binary file not shown.
4.02 KB
Binary file not shown.
4.09 KB
Binary file not shown.

0 commit comments

Comments
 (0)