line spectrum
This commit is contained in:
1 parent
395f9a2c4a
commit
c04fcb1ef6
7 files changed
+206
-54
No files matched your search
+26
-41
@@ -1,46 +1,31 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class LineSpectrum : TripsitterAve
|
public class LineSpectrum : TripsitterAve {
|
||||||
{
|
private GameObject[] _spectrumBars;
|
||||||
private GameObject[] _spectrumBars;
|
private Vector3[] _originalPositions;
|
||||||
private Vector3[] _originalPositions;
|
private Vector3 _originalScale;
|
||||||
private Vector3 _originalScale;
|
|
||||||
|
|
||||||
public GameObject Prefab;
|
private float AudioScale = 10;
|
||||||
public float AudioScale;
|
private float Power = 1.5f;
|
||||||
public float Power;
|
|
||||||
|
|
||||||
public void Start()
|
void Start() {
|
||||||
{
|
LineRenderer lineRenderer = gameObject.AddComponent<LineRenderer>();
|
||||||
_spectrumBars = new GameObject[SpectrumSize];
|
lineRenderer.material = new Material(Shader.Find("Sprites/Default"));
|
||||||
_originalPositions = new Vector3[SpectrumSize];
|
lineRenderer.widthMultiplier = 0.5f;
|
||||||
_originalScale = Prefab.transform.localScale;
|
lineRenderer.positionCount = SpectrumSize;
|
||||||
|
Debug.Log("{SpectrumSize}");
|
||||||
var width = Prefab.transform.localScale.x;
|
|
||||||
|
|
||||||
for (var i = 0; i < SpectrumSize; i++)
|
|
||||||
{
|
|
||||||
var spectrumBar = GameObject.Instantiate(Prefab);
|
|
||||||
spectrumBar.transform.parent = transform;
|
|
||||||
spectrumBar.transform.localPosition = new Vector3(width * i, 0.0f, 0.0f);
|
|
||||||
_spectrumBars[i] = spectrumBar;
|
|
||||||
_originalPositions[i] = spectrumBar.transform.localPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
Prefab.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update()
|
|
||||||
{
|
|
||||||
var spectrumData = GetSpectrumData();
|
|
||||||
|
|
||||||
for (var i = 0; i < SpectrumSize; i++)
|
|
||||||
{
|
|
||||||
var audioScale = Mathf.Pow(spectrumData[i] * AudioScale, Power);
|
|
||||||
var newScale = new Vector3(_originalScale.x, _originalScale.y + audioScale, _originalScale.z);
|
|
||||||
var halfScale = newScale / 2.0f;
|
|
||||||
_spectrumBars[i].transform.localPosition = new Vector3(_originalPositions[i].x + halfScale.x, _originalPositions[i].y + halfScale.y, _originalPositions[i].z + halfScale.z);
|
|
||||||
_spectrumBars[i].transform.localScale = newScale;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Update() {
|
||||||
|
LineRenderer lineRenderer = GetComponent<LineRenderer>();
|
||||||
|
var spectrumData = GetSpectrumData();
|
||||||
|
var points = new Vector3[SpectrumSize];
|
||||||
|
for (int i = 0; i < SpectrumSize; i++)
|
||||||
|
{
|
||||||
|
var audioScale = Mathf.Pow(spectrumData[i] * AudioScale, Power);
|
||||||
|
points[i] = new Vector3(i * 1.0f, audioScale, 0.0f);
|
||||||
|
}
|
||||||
|
lineRenderer.SetPositions(points);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!21 &2100000
|
||||||
|
Material:
|
||||||
|
serializedVersion: 6
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: Dark
|
||||||
|
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_ShaderKeywords:
|
||||||
|
m_LightmapFlags: 4
|
||||||
|
m_EnableInstancingVariants: 0
|
||||||
|
m_DoubleSidedGI: 0
|
||||||
|
m_CustomRenderQueue: -1
|
||||||
|
stringTagMap: {}
|
||||||
|
disabledShaderPasses: []
|
||||||
|
m_SavedProperties:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TexEnvs:
|
||||||
|
- _BumpMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailAlbedoMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailMask:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailNormalMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _EmissionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MainTex:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MetallicGlossMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _OcclusionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ParallaxMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_Floats:
|
||||||
|
- _BumpScale: 1
|
||||||
|
- _Cutoff: 0.5
|
||||||
|
- _DetailNormalMapScale: 1
|
||||||
|
- _DstBlend: 0
|
||||||
|
- _GlossMapScale: 1
|
||||||
|
- _Glossiness: 0.125
|
||||||
|
- _GlossyReflections: 1
|
||||||
|
- _Metallic: 0
|
||||||
|
- _Mode: 0
|
||||||
|
- _OcclusionStrength: 1
|
||||||
|
- _Parallax: 0.02
|
||||||
|
- _SmoothnessTextureChannel: 0
|
||||||
|
- _SpecularHighlights: 1
|
||||||
|
- _SrcBlend: 1
|
||||||
|
- _UVSec: 0
|
||||||
|
- _ZWrite: 1
|
||||||
|
m_Colors:
|
||||||
|
- _Color: {r: 0.3301887, g: 0.3301887, b: 0.3301887, a: 1}
|
||||||
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 983c52e1e2bf37e478f9c9609feba7e8
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 2100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+65
-12
@@ -123,6 +123,52 @@ NavMeshSettings:
|
|||||||
debug:
|
debug:
|
||||||
m_Flags: 0
|
m_Flags: 0
|
||||||
m_NavMeshData: {fileID: 0}
|
m_NavMeshData: {fileID: 0}
|
||||||
|
--- !u!1 &285484267
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 285484269}
|
||||||
|
- component: {fileID: 285484270}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: LineSpectrum
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &285484269
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 285484267}
|
||||||
|
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_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 5
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &285484270
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 285484267}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 3e141da9e070ef843b956c27c9e9f8f4, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
WasapiAudioSource: {fileID: 0}
|
||||||
|
Preview:
|
||||||
|
Values: []
|
||||||
--- !u!1 &523739710
|
--- !u!1 &523739710
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -408,7 +454,7 @@ GameObject:
|
|||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!114 &1560384703
|
--- !u!114 &1560384703
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -437,7 +483,8 @@ Transform:
|
|||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0.29113126, y: 1.740408, z: -0.52083397}
|
m_LocalPosition: {x: 0.29113126, y: 1.740408, z: -0.52083397}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children:
|
||||||
|
- {fileID: 1998037178}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 4
|
m_RootOrder: 4
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
@@ -446,28 +493,33 @@ GameObject:
|
|||||||
m_CorrespondingSourceObject: {fileID: 3951425291114222009, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
m_CorrespondingSourceObject: {fileID: 3951425291114222009, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
||||||
m_PrefabInstance: {fileID: 3951425289854923023}
|
m_PrefabInstance: {fileID: 3951425289854923023}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!4 &1998037178 stripped
|
||||||
|
Transform:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 3951425289854923023}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
--- !u!1001 &3951425289854923023
|
--- !u!1001 &3951425289854923023
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Modification:
|
m_Modification:
|
||||||
m_TransformParent: {fileID: 0}
|
m_TransformParent: {fileID: 1560384704}
|
||||||
m_Modifications:
|
m_Modifications:
|
||||||
- target: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
- target: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
||||||
propertyPath: m_RootOrder
|
propertyPath: m_RootOrder
|
||||||
value: 5
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
- target: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
||||||
propertyPath: m_LocalPosition.x
|
propertyPath: m_LocalPosition.x
|
||||||
value: 15.407915
|
value: 15.116784
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
- target: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
||||||
propertyPath: m_LocalPosition.y
|
propertyPath: m_LocalPosition.y
|
||||||
value: 4.7623067
|
value: 3.0218987
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
- target: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
||||||
propertyPath: m_LocalPosition.z
|
propertyPath: m_LocalPosition.z
|
||||||
value: 1.3299046
|
value: 1.8507385
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
- target: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
||||||
propertyPath: m_LocalRotation.w
|
propertyPath: m_LocalRotation.w
|
||||||
@@ -475,15 +527,15 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
- target: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
||||||
propertyPath: m_LocalRotation.x
|
propertyPath: m_LocalRotation.x
|
||||||
value: 0
|
value: -0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
- target: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
||||||
propertyPath: m_LocalRotation.y
|
propertyPath: m_LocalRotation.y
|
||||||
value: 0
|
value: -0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
- target: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
||||||
propertyPath: m_LocalRotation.z
|
propertyPath: m_LocalRotation.z
|
||||||
value: 0
|
value: -0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
- target: {fileID: 3951425291114222005, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
||||||
propertyPath: m_LocalEulerAnglesHint.x
|
propertyPath: m_LocalEulerAnglesHint.x
|
||||||
@@ -508,6 +560,7 @@ PrefabInstance:
|
|||||||
- target: {fileID: 7554796985381095928, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
- target: {fileID: 7554796985381095928, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
||||||
propertyPath: m_Materials.Array.data[0]
|
propertyPath: m_Materials.Array.data[0]
|
||||||
value:
|
value:
|
||||||
objectReference: {fileID: 2100000, guid: 5f414642c01e9af40b8c60a6c7162c5a, type: 2}
|
objectReference: {fileID: 2100000, guid: 983c52e1e2bf37e478f9c9609feba7e8, type: 2}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents:
|
||||||
|
- {fileID: 7554796985381095928, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: c67cf5d0160fa1340afc79b251a0c205, type: 3}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6bc85cde073f1cd4880d3fd624ecbb56
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e10968888ba427849925c2f957333999
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -589,7 +589,20 @@ PlayerSettings:
|
|||||||
webGLLinkerTarget: 1
|
webGLLinkerTarget: 1
|
||||||
webGLThreadsSupport: 0
|
webGLThreadsSupport: 0
|
||||||
webGLDecompressionFallback: 0
|
webGLDecompressionFallback: 0
|
||||||
scriptingDefineSymbols: {}
|
scriptingDefineSymbols:
|
||||||
|
1: UNITY_POST_PROCESSING_STACK_V2
|
||||||
|
7: UNITY_POST_PROCESSING_STACK_V2
|
||||||
|
13: UNITY_POST_PROCESSING_STACK_V2
|
||||||
|
14: UNITY_POST_PROCESSING_STACK_V2
|
||||||
|
19: UNITY_POST_PROCESSING_STACK_V2
|
||||||
|
21: UNITY_POST_PROCESSING_STACK_V2
|
||||||
|
25: UNITY_POST_PROCESSING_STACK_V2
|
||||||
|
27: UNITY_POST_PROCESSING_STACK_V2
|
||||||
|
28: UNITY_POST_PROCESSING_STACK_V2
|
||||||
|
29: UNITY_POST_PROCESSING_STACK_V2
|
||||||
|
30: UNITY_POST_PROCESSING_STACK_V2
|
||||||
|
32: UNITY_POST_PROCESSING_STACK_V2
|
||||||
|
33: UNITY_POST_PROCESSING_STACK_V2
|
||||||
additionalCompilerArguments: {}
|
additionalCompilerArguments: {}
|
||||||
platformArchitecture: {}
|
platformArchitecture: {}
|
||||||
scriptingBackend: {}
|
scriptingBackend: {}
|
||||||
|
|||||||
Reference in new issue
Block a user