Skip to content

Commit 20bd9bd

Browse files
committed
Build
1 parent cb2822c commit 20bd9bd

File tree

391 files changed

+62899
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

391 files changed

+62899
-0
lines changed

.gitignore

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# This .gitignore file should be placed at the root of your Unity project directory
2+
#
3+
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
4+
#
5+
/[Ll]ibrary/
6+
/[Tt]emp/
7+
/[Oo]bj/
8+
/[Bb]uild/
9+
/[Bb]uilds/
10+
/[Ll]ogs/
11+
/[Uu]ser[Ss]ettings/
12+
13+
# MemoryCaptures can get excessive in size.
14+
# They also could contain extremely sensitive data
15+
/[Mm]emoryCaptures/
16+
17+
# Recordings can get excessive in size
18+
/[Rr]ecordings/
19+
20+
# Uncomment this line if you wish to ignore the asset store tools plugin
21+
# /[Aa]ssets/AssetStoreTools*
22+
23+
# Autogenerated Jetbrains Rider plugin
24+
/[Aa]ssets/Plugins/Editor/JetBrains*
25+
26+
# Visual Studio cache directory
27+
.vs/
28+
29+
# Gradle cache directory
30+
.gradle/
31+
32+
# Autogenerated VS/MD/Consulo solution and project files
33+
ExportedObj/
34+
.consulo/
35+
*.csproj
36+
*.unityproj
37+
*.sln
38+
*.suo
39+
*.tmp
40+
*.user
41+
*.userprefs
42+
*.pidb
43+
*.booproj
44+
*.svd
45+
*.pdb
46+
*.mdb
47+
*.opendb
48+
*.VC.db
49+
50+
# Unity3D generated meta files
51+
*.pidb.meta
52+
*.pdb.meta
53+
*.mdb.meta
54+
55+
# Unity3D generated file on crash reports
56+
sysinfo.txt
57+
58+
# Builds
59+
*.apk
60+
*.aab
61+
*.unitypackage
62+
*.app
63+
64+
# Crashlytics generated file
65+
crashlytics-build.properties
66+
67+
# Packed Addressables
68+
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
69+
70+
# Temporary auto-generated Android Assets
71+
/[Aa]ssets/[Ss]treamingAssets/aa.meta
72+
/[Aa]ssets/[Ss]treamingAssets/aa/*
73+
/Unity-WEBGL-LoadAudioStreamingAssets/Library
74+
/Unity-WEBGL-LoadAudioStreamingAssets/Logs
75+
/.idea
76+
/Unity-WEBGL-LoadAudioStreamingAssets/Temp
77+
/Unity-WEBGL-LoadAudioStreamingAssets/.idea
78+
79+
**.mp3
80+
/Unity-WEBGL-LoadAudioStreamingAssets/UserSettings

Unity-WEBGL-LoadAudioStreamingAssets/Assets/Internal.meta

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

Unity-WEBGL-LoadAudioStreamingAssets/Assets/Internal/Codebase.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
using UnityEngine;
2+
using UnityEngine.UI;
3+
using System.Collections;
4+
using UnityEngine.Networking;
5+
using Object = UnityEngine.Object;
6+
7+
namespace RimuruDev.Internal.Codebase
8+
{
9+
[DisallowMultipleComponent]
10+
public sealed class Game : MonoBehaviour
11+
{
12+
/// <summary>
13+
/// Path to audio -> Assets/StreamingAssets/BigMusic.mp3
14+
/// </summary>
15+
[Space]
16+
[SerializeField] private string audioFileName = "BigMusic.mp3";
17+
[Space]
18+
[SerializeField] private AudioSource audioSource;
19+
[SerializeField] private Button loadButton;
20+
[SerializeField] private Button disposeButton;
21+
[Space]
22+
[SerializeField] private bool debugLogEnable = true;
23+
private AudioClip audioClip;
24+
25+
private void Reset()
26+
{
27+
audioFileName = "BigMusic.mp3";
28+
29+
if (audioSource == null)
30+
audioSource = FindObjectOfType<AudioSource>(true);
31+
32+
if (loadButton == null)
33+
loadButton = GameObject.Find("LoadAudio").GetComponent<Button>();
34+
35+
if (disposeButton == null)
36+
disposeButton = GameObject.Find("DisposeAudio").GetComponent<Button>();
37+
38+
if (FindObjectOfType<AudioListener>(true) == null)
39+
new GameObject().AddComponent<AudioListener>();
40+
}
41+
42+
private void Awake()
43+
{
44+
Debug.unityLogger.logEnabled = debugLogEnable;
45+
46+
loadButton.onClick.AddListener(Load);
47+
disposeButton.onClick.AddListener(Dispose);
48+
}
49+
50+
private void Start()
51+
{
52+
DebugLogAndButtonLock(null, true, this);
53+
}
54+
55+
private void OnDestroy()
56+
{
57+
loadButton.onClick.RemoveListener(Load);
58+
disposeButton.onClick.RemoveListener(Dispose);
59+
}
60+
61+
private void Load()
62+
{
63+
DebugLogAndButtonLock(nameof(Load), false, this);
64+
StartCoroutine(LoadAudio());
65+
}
66+
67+
private IEnumerator LoadAudio()
68+
{
69+
var path = System.IO.Path.Combine(Application.streamingAssetsPath, audioFileName);
70+
71+
Debug.Log($"Loading from path: {path}");
72+
73+
using var www = UnityWebRequestMultimedia.GetAudioClip(path, AudioType.MPEG);
74+
75+
yield return www.SendWebRequest();
76+
77+
if (www.result is UnityWebRequest.Result.ConnectionError or UnityWebRequest.Result.ProtocolError)
78+
{
79+
Debug.LogError(www.error);
80+
}
81+
else
82+
{
83+
audioClip = DownloadHandlerAudioClip.GetContent(www);
84+
audioSource.clip = audioClip;
85+
audioSource.Play();
86+
}
87+
}
88+
89+
private void Dispose()
90+
{
91+
DebugLogAndButtonLock(nameof(Dispose), true, this);
92+
93+
if (audioSource.isPlaying)
94+
audioSource.Stop();
95+
96+
if (audioClip != null)
97+
{
98+
audioSource.clip = null;
99+
Resources.UnloadUnusedAssets();
100+
audioClip = null;
101+
}
102+
}
103+
104+
private void DebugLogAndButtonLock(string methodName, bool state, Object sender = null)
105+
{
106+
if (!string.IsNullOrWhiteSpace(methodName))
107+
Debug.Log($"Perform {methodName}", sender);
108+
109+
loadButton.interactable = state;
110+
disposeButton.interactable = !state;
111+
}
112+
}
113+
}

Unity-WEBGL-LoadAudioStreamingAssets/Assets/Internal/Codebase/Game.cs.meta

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

Unity-WEBGL-LoadAudioStreamingAssets/Assets/Internal/Scenes.meta

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

0 commit comments

Comments
 (0)