Skip to content

Commit d316e25

Browse files
committed
Initial commit
0 parents  commit d316e25

File tree

84 files changed

+4633
-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.

84 files changed

+4633
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[Ll]ibrary/
2+
[Tt]emp/
3+
[Oo]bj/
4+
[Bb]uild/
5+
[Bb]uilds/
6+
Assets/AssetStoreTools*
7+
8+
# Visual Studio cache directory
9+
.vs/
10+
11+
# Autogenerated VS/MD/Consulo solution and project files
12+
ExportedObj/
13+
.consulo/
14+
*.csproj
15+
*.unityproj
16+
*.sln
17+
*.suo
18+
*.tmp
19+
*.user
20+
*.userprefs
21+
*.pidb
22+
*.booproj
23+
*.svd
24+
*.pdb
25+
*.opendb
26+
*.VC.db
27+
28+
# Unity3D generated meta files
29+
*.pidb.meta
30+
*.pdb.meta
31+
32+
# Unity3D Generated File On Crash Reports
33+
sysinfo.txt
34+
35+
# Builds
36+
*.apk
37+
*.unitypackage

Assets/AudioTexture.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AudioTexture/Editor.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using UnityEditor;
5+
6+
namespace AudioTexture
7+
{
8+
public class AudioTextureGenerator : ScriptableWizard
9+
{
10+
[SerializeField] private AudioClip audioClip;
11+
12+
[MenuItem("AudioTexture/Generate")]
13+
static void Open()
14+
{
15+
DisplayWizard<AudioTextureGenerator>("Generate amplitude AudioTexture");
16+
}
17+
18+
private void OnWizardCreate()
19+
{
20+
if (audioClip.channels > 2)
21+
{
22+
Debug.LogError("Currently supports only 1ch or 2ch audio.");
23+
return;
24+
}
25+
26+
var data = new float[audioClip.samples * audioClip.channels];
27+
audioClip.GetData(data, 0);
28+
29+
var width = Mathf.CeilToInt(Mathf.Sqrt(audioClip.samples));
30+
var height = width;
31+
var texture = new Texture2D(width, height, TextureFormat.RGFloat, false, true);
32+
var colors = new Color[width * height];
33+
34+
if (audioClip.channels == 1)
35+
{
36+
for (int i = 0; i < audioClip.samples; i++)
37+
{
38+
colors[i] = new Color((data[i] + 1.0f) / 2.0f, (data[i] + 1.0f) / 2.0f, 0);
39+
}
40+
}
41+
else
42+
{
43+
for (int i = 0; i < audioClip.samples; i++)
44+
{
45+
colors[i] = new Color((data[i * 2] + 1.0f) / 2.0f, (data[i * 2 + 1] + 1.0f) / 2.0f, 0);
46+
}
47+
}
48+
49+
texture.SetPixels(colors);
50+
ProjectWindowUtil.CreateAsset(texture, audioClip.name + ".asset");
51+
}
52+
53+
private SerializedObject _serializedObject;
54+
55+
private void OnEnable()
56+
{
57+
_serializedObject = new SerializedObject(this);
58+
}
59+
60+
protected override bool DrawWizardGUI()
61+
{
62+
_serializedObject.Update();
63+
EditorGUILayout.PropertyField(_serializedObject.FindProperty("audioClip"));
64+
_serializedObject.ApplyModifiedProperties();
65+
return true;
66+
}
67+
}
68+
}

Assets/AudioTexture/Editor/AudioTextureGenerator.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AudioTexture/Examples.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AudioTexture/Examples/Audio.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AudioTexture/Examples/Audio/UCL2.0.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AudioTexture/Examples/Audio/UCL2.0/English.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AudioTexture/Examples/Audio/UCL2.0/English/01Unity-Chan License Terms and Condition_EN_UCL2.0.pdf.meta

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AudioTexture/Examples/Audio/UCL2.0/English/02Unity-Chan License Terms and Condition_Summary_EN_UCL2.0.pdf.meta

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AudioTexture/Examples/Audio/UCL2.0/English/03Indication of License_EN_UCL2.0.pdf.meta

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AudioTexture/Examples/Audio/UCL2.0/Japanese.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AudioTexture/Examples/Audio/UCL2.0/Japanese/01Unity-Chan License Terms and Condition_JP_UCL2.0.pdf.meta

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AudioTexture/Examples/Audio/UCL2.0/Japanese/02Unity-Chan License Terms and Condition_Summary_JP_UCL2.0.pdf.meta

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AudioTexture/Examples/Audio/UCL2.0/Japanese/03Indication of License_JP_UCL2.0.pdf.meta

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AudioTexture/Examples/Audio/UCL2.0/License Logo.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)