private void CallReceivedSpawnAsset(SpawnAsset spawnAsset, UdpManager.ReceivedMessage.Sender sender) { if (ReceivedSpawnAsset != null) { foreach (ReceivedSpawnAssetDelegated Callack in ReceivedSpawnAsset.GetInvocationList()) { try { Callack(spawnAsset, sender); } catch (System.Exception ex) { Debug.LogException(ex); } } } }
// Override this method in a derived class to receive additional json-serialized classes. protected virtual void ReceivedEventMessage(string jsonString, uint eventIdentifier, UdpManager.ReceivedMessage.Sender sender) { //Debug.Log("Received JSON: " + jsonString); switch (eventIdentifier) { case EventIdentifierBase.ASSET_TRANSFORM: TransformAsset transformAsset = JsonUtility.FromJson <TransformAsset>(jsonString); CallReceivedTransformAsset(transformAsset, sender); break; case EventIdentifierBase.ASSET_SPAWN: SpawnAsset spawnAsset = JsonUtility.FromJson <SpawnAsset>(jsonString); CallReceivedSpawnAsset(spawnAsset, sender); break; case EventIdentifierBase.ASSET_FOV: FieldOfViewAsset fovAsset = JsonUtility.FromJson <FieldOfViewAsset>(jsonString); CallReceivedFieldOfViewMessage(fovAsset, sender); break; case EventIdentifierBase.SETTING_MESSAGE: SettingMessage settingMessage = JsonUtility.FromJson <SettingMessage>(jsonString); if (settingMessage.valueType == SettingMessage.ValueType.FLOAT) { SettingMessageFloat settingMessageFloat = JsonUtility.FromJson <SettingMessageFloat>(jsonString); CallReceivedSettingMessage(settingMessageFloat, sender); } else { Debug.LogWarning("Setting Message was received, but value type has not yet been implemented. This message is dismissed."); } break; default: Debug.LogWarning("Received Event of Type " + EventIdentifierBase.GetIdentifierName(eventIdentifier) + "(" + eventIdentifier + ") but it was not handled."); break; } }