Everything seems to work better. Pretty basic, and needs testing, but it works.
This commit is contained in:
parent
eabb7f95e4
commit
05af0a696b
@ -2407,7 +2407,6 @@ MonoBehaviour:
|
||||
PrefabModifications: []
|
||||
SerializationNodes: []
|
||||
_udonSharpBackingUdonBehaviour: {fileID: 51189181}
|
||||
_PermissionsPanel: {fileID: 824788962}
|
||||
_MikedVoiceDistanceNear: 30
|
||||
_MikedVoiceDistanceFar: 60
|
||||
--- !u!135 &51189183
|
||||
@ -19294,7 +19293,6 @@ MonoBehaviour:
|
||||
PrefabModifications: []
|
||||
SerializationNodes: []
|
||||
_udonSharpBackingUdonBehaviour: {fileID: 344488390}
|
||||
_PermissionsPanel: {fileID: 824788962}
|
||||
_MikedVoiceDistanceNear: 0
|
||||
_MikedVoiceDistanceFar: 5
|
||||
--- !u!1 &344722282 stripped
|
||||
@ -23256,7 +23254,6 @@ MonoBehaviour:
|
||||
PrefabModifications: []
|
||||
SerializationNodes: []
|
||||
_udonSharpBackingUdonBehaviour: {fileID: 431721602}
|
||||
_PermissionsPanel: {fileID: 824788962}
|
||||
_MikedVoiceDistanceNear: 30
|
||||
_MikedVoiceDistanceFar: 60
|
||||
--- !u!135 &431721604
|
||||
@ -37559,7 +37556,6 @@ MonoBehaviour:
|
||||
PrefabModifications: []
|
||||
SerializationNodes: []
|
||||
_udonSharpBackingUdonBehaviour: {fileID: 772205215}
|
||||
_PermissionsPanel: {fileID: 824788962}
|
||||
_MikedVoiceDistanceNear: 30
|
||||
_MikedVoiceDistanceFar: 60
|
||||
--- !u!65 &772205217
|
||||
|
||||
@ -44,88 +44,22 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 5
|
||||
Data: 4
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: _PermissionsPanel
|
||||
Data: _MikedVoiceDistanceNear
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: _PermissionsPanel
|
||||
Data: _MikedVoiceDistanceNear
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 3|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: PermissionsPanel, Assembly-CSharp
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 4|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: VRC.Udon.UdonBehaviour, VRC.Udon
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
- Name:
|
||||
Entry: 6
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: true
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 1
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data: 6|UnityEngine.SerializeField, UnityEngine.CoreModule
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: _MikedVoiceDistanceNear
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 7|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: _MikedVoiceDistanceNear
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 8|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: System.Single, mscorlib
|
||||
@ -134,7 +68,7 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 8
|
||||
Data: 3
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@ -149,13 +83,13 @@ MonoBehaviour:
|
||||
Data: true
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 9|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 4|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 1
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data: 10|UnityEngine.SerializeField, UnityEngine.CoreModule
|
||||
Data: 5|UnityEngine.SerializeField, UnityEngine.CoreModule
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
@ -179,16 +113,16 @@ MonoBehaviour:
|
||||
Data: _MikedVoiceDistanceFar
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 11|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: _MikedVoiceDistanceFar
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 8
|
||||
Data: 3
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 8
|
||||
Data: 3
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@ -203,13 +137,13 @@ MonoBehaviour:
|
||||
Data: true
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 12|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 7|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 1
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data: 13|UnityEngine.SerializeField, UnityEngine.CoreModule
|
||||
Data: 8|UnityEngine.SerializeField, UnityEngine.CoreModule
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
@ -230,16 +164,16 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: _MicrophoneEnabled
|
||||
Data: _Enabled
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 14|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: _MicrophoneEnabled
|
||||
Data: _Enabled
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 15|System.RuntimeType, mscorlib
|
||||
Data: 10|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: System.Boolean, mscorlib
|
||||
@ -248,7 +182,7 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 15
|
||||
Data: 10
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@ -263,13 +197,13 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 16|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 11|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 1
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data: 17|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
|
||||
Data: 12|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
@ -290,25 +224,25 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: _LocalOverlapCounter
|
||||
Data: _QueuedPlayers
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 18|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 13|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: _LocalOverlapCounter
|
||||
Data: _QueuedPlayers
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 19|System.RuntimeType, mscorlib
|
||||
Data: 14|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: System.Int32, mscorlib
|
||||
Data: VRC.SDKBase.VRCPlayerApi[], VRCSDKBase
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 19
|
||||
Data: 14
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@ -323,7 +257,7 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 20|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 15|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
|
||||
@ -8,14 +8,13 @@ using VRC.Udon.Common;
|
||||
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
|
||||
public class Microphone : UdonSharpBehaviour
|
||||
{
|
||||
[SerializeField] private PermissionsPanel _PermissionsPanel;
|
||||
|
||||
[SerializeField] private float _MikedVoiceDistanceNear = 30.0f;
|
||||
[SerializeField] private float _MikedVoiceDistanceFar = 60.0f;
|
||||
|
||||
[UdonSynced] private bool _MicrophoneEnabled = false;
|
||||
[UdonSynced] private bool _Enabled = false;
|
||||
|
||||
private int _LocalOverlapCounter = 0;
|
||||
private VRCPlayerApi[] _QueuedPlayers = new VRCPlayerApi[MAX_PLAYERS];
|
||||
private const int MAX_PLAYERS = 100;
|
||||
|
||||
private const float DEFAULT_VOICE_DISTANCE_NEAR = 0.0f;
|
||||
private const float DEFAULT_VOICE_DISTANCE_FAR = 25.0f;
|
||||
@ -24,16 +23,26 @@ public class Microphone : UdonSharpBehaviour
|
||||
public override void OnDeserialization(DeserializationResult Result)
|
||||
{
|
||||
_EnableMicrophone_Synced();
|
||||
|
||||
base.OnDeserialization(Result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void OnPlayerTriggerEnter(VRCPlayerApi Player)
|
||||
{
|
||||
if (Player == Networking.LocalPlayer)
|
||||
for (int i = 0; i < _QueuedPlayers.Length; i++)
|
||||
{
|
||||
_LocalOverlapCounter++;
|
||||
_UpdateMicrophoneEffect();
|
||||
if (_QueuedPlayers[i] == null)
|
||||
{
|
||||
_QueuedPlayers[i] = Player;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_Enabled)
|
||||
{
|
||||
Player.SetVoiceDistanceNear(_MikedVoiceDistanceNear);
|
||||
Player.SetVoiceDistanceFar(_MikedVoiceDistanceFar);
|
||||
}
|
||||
|
||||
base.OnPlayerTriggerEnter(Player);
|
||||
@ -41,10 +50,19 @@ public class Microphone : UdonSharpBehaviour
|
||||
|
||||
public override void OnPlayerTriggerExit(VRCPlayerApi Player)
|
||||
{
|
||||
if (Player == Networking.LocalPlayer)
|
||||
for (int i = 0; i < _QueuedPlayers.Length; i++)
|
||||
{
|
||||
_LocalOverlapCounter--;
|
||||
_UpdateMicrophoneEffect();
|
||||
if (_QueuedPlayers[i] == Player)
|
||||
{
|
||||
_QueuedPlayers[i] = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_Enabled)
|
||||
{
|
||||
Player.SetVoiceDistanceNear(DEFAULT_VOICE_DISTANCE_NEAR);
|
||||
Player.SetVoiceDistanceFar(DEFAULT_VOICE_DISTANCE_FAR);
|
||||
}
|
||||
|
||||
base.OnPlayerTriggerExit(Player);
|
||||
@ -52,22 +70,16 @@ public class Microphone : UdonSharpBehaviour
|
||||
|
||||
public override void OnPlayerJoined(VRCPlayerApi Player)
|
||||
{
|
||||
if (Player == Networking.LocalPlayer)
|
||||
{
|
||||
Networking.LocalPlayer.SetVoiceDistanceNear(DEFAULT_VOICE_DISTANCE_NEAR);
|
||||
Networking.LocalPlayer.SetVoiceDistanceFar(DEFAULT_VOICE_DISTANCE_FAR);
|
||||
}
|
||||
Player.SetVoiceDistanceNear(DEFAULT_VOICE_DISTANCE_NEAR);
|
||||
Player.SetVoiceDistanceFar(DEFAULT_VOICE_DISTANCE_FAR);
|
||||
|
||||
base.OnPlayerJoined(Player);
|
||||
}
|
||||
|
||||
public override void OnPlayerLeft(VRCPlayerApi Player)
|
||||
{
|
||||
if (Player == Networking.LocalPlayer)
|
||||
{
|
||||
Networking.LocalPlayer.SetVoiceDistanceNear(DEFAULT_VOICE_DISTANCE_NEAR);
|
||||
Networking.LocalPlayer.SetVoiceDistanceFar(DEFAULT_VOICE_DISTANCE_FAR);
|
||||
}
|
||||
Player.SetVoiceDistanceNear(DEFAULT_VOICE_DISTANCE_NEAR);
|
||||
Player.SetVoiceDistanceFar(DEFAULT_VOICE_DISTANCE_FAR);
|
||||
|
||||
base.OnPlayerLeft(Player);
|
||||
}
|
||||
@ -77,20 +89,21 @@ public class Microphone : UdonSharpBehaviour
|
||||
{
|
||||
if (Networking.IsOwner(gameObject))
|
||||
{
|
||||
_MicrophoneEnabled = Enable;
|
||||
_Enabled = Enable;
|
||||
_EnableMicrophone_Synced();
|
||||
RequestSerialization();
|
||||
}
|
||||
}
|
||||
private void _EnableMicrophone_Synced()
|
||||
{
|
||||
_UpdateMicrophoneEffect();
|
||||
}
|
||||
|
||||
|
||||
private void _UpdateMicrophoneEffect()
|
||||
{
|
||||
Networking.LocalPlayer.SetVoiceDistanceNear((_MicrophoneEnabled && _LocalOverlapCounter > 0) ? _MikedVoiceDistanceNear : DEFAULT_VOICE_DISTANCE_NEAR);
|
||||
Networking.LocalPlayer.SetVoiceDistanceFar((_MicrophoneEnabled && _LocalOverlapCounter > 0) ? _MikedVoiceDistanceFar : DEFAULT_VOICE_DISTANCE_FAR);
|
||||
for (int i = 0; i < _QueuedPlayers.Length; i++)
|
||||
{
|
||||
if (_QueuedPlayers[i] != null)
|
||||
{
|
||||
_QueuedPlayers[i].SetVoiceDistanceNear(_Enabled ? _MikedVoiceDistanceNear : DEFAULT_VOICE_DISTANCE_NEAR);
|
||||
_QueuedPlayers[i].SetVoiceDistanceFar(_Enabled ? _MikedVoiceDistanceFar : DEFAULT_VOICE_DISTANCE_FAR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
|
||||
m_Name: BoneFollower
|
||||
m_EditorClassIdentifier:
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: 52ecc8a73071e8e40928c3609699fcf4,
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: ccbda9bf23e2f714c9226283c77a92e5,
|
||||
type: 2}
|
||||
udonAssembly:
|
||||
assemblyError:
|
||||
|
||||
@ -12,7 +12,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
|
||||
m_Name: InteractToggle
|
||||
m_EditorClassIdentifier:
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: 873dfce61b1514e429c92e0d2fded7de,
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: 405e38d3dfb2f514daeed0e28fbb4864,
|
||||
type: 2}
|
||||
udonAssembly:
|
||||
assemblyError:
|
||||
|
||||
@ -12,7 +12,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
|
||||
m_Name: PlayerModSetter
|
||||
m_EditorClassIdentifier:
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: e81558796a212ab4d88e305e2010f24b,
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: f938e6c4ff027a74da405a1f9353fd2b,
|
||||
type: 2}
|
||||
udonAssembly:
|
||||
assemblyError:
|
||||
|
||||
@ -12,7 +12,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
|
||||
m_Name: GlobalToggleObject
|
||||
m_EditorClassIdentifier:
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: 2fe8ced6184000f49bca526cd2c5891c,
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: c49c9265a3ef24642a6a4465d0a78872,
|
||||
type: 2}
|
||||
udonAssembly:
|
||||
assemblyError:
|
||||
|
||||
@ -12,7 +12,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
|
||||
m_Name: MasterToggleObject
|
||||
m_EditorClassIdentifier:
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: a2d01d9f36ac6df49831be249e48ecc4,
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: 04024a76ab1924042ba521e11cb76d91,
|
||||
type: 2}
|
||||
udonAssembly:
|
||||
assemblyError:
|
||||
|
||||
@ -12,7 +12,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
|
||||
m_Name: TrackingDataFollower
|
||||
m_EditorClassIdentifier:
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: 1b89d4552983c0448a7389decec3b555,
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: 17f8fbbe6cc186d4f8dbb057b01a4ec2,
|
||||
type: 2}
|
||||
udonAssembly:
|
||||
assemblyError:
|
||||
|
||||
@ -12,7 +12,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
|
||||
m_Name: WorldAudioSettings
|
||||
m_EditorClassIdentifier:
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: 994b559b0f158b4499f8937980ed8694,
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: 128d924a3066b7546b2d1c73e61006ab,
|
||||
type: 2}
|
||||
udonAssembly:
|
||||
assemblyError:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user