private void InitializeTemporaryMeshCluster() { var meshes = SoundToolKitManager.Instance.ResourceContainer.AcousticMeshes; if (meshes.Any(x => x.MeshCluster == null)) { m_temporaryCluster = ScriptableObject.CreateInstance <SoundToolKitMeshCluster>(); m_temporaryCluster.name = "Temporary Mesh Cluster"; MeshClusters.Add(m_temporaryCluster); SoundToolKitDebug.Log("Temporary SoundToolKitMeshCluster created for the duration of the playtime " + "in order to load all of the SoundToolKitMeshes that have no MeshCluster assigned. \n" + "To make this permanent and suppress this message use the menu " + "Tools/SoundToolKit/Geometry/SynchronizeDefaultGeometry after exiting the PlayMode. \n" + "In order not to load specific SoundToolKitMeshes, assign them to " + "a MeshCluster that is not added to the SoundToolKitGeometry's MeshClusters field."); foreach (var mesh in meshes) { if (mesh.MeshCluster == null) { mesh.MeshCluster = MeshClusters.Last(); } } } }
private void Start() { MeshClusters.ForEach(x => { if (x != null && x != m_temporaryCluster) { x.SaveStateForPlaymode(); } }); }
internal void ClearGeometry() { MeshClusters.ForEach(x => { if (x != null) { UnloadMeshCluster(x); } }); SoundToolKitManager.Instance.StkAudioEngine.Scene.Clear(); SoundToolKitManager.Instance.ResourceContainer.Geometry = null; }
internal void SerializeGeometry() { MeshClusters.ForEach(x => { if (x != null && x != m_temporaryCluster) { x.Serialize(); } else if (x == m_temporaryCluster) { SoundToolKitDebug.Log("Temporary Mesh Cluster can't be serialized."); } }); }
internal void InitializeMeshClusters() { if (!Initialized && SoundToolKitManager.Instance.ResourceContainer.AcousticMeshes.Any()) { InitializeTemporaryMeshCluster(); MeshClusters.ForEach(x => { if (x != null) { LoadMeshCluster(x); } }); Initialized = true; } }
private void OnDestroy() { if (SoundToolKitManager.Instance != null) { ClearGeometry(); } MeshClusters.ForEach(x => { if (x != null && x != m_temporaryCluster) { x.RestoreStateForEditmode(); } }); m_temporaryCluster = null; MeshDeletionUpdater.Destroy(); }
/// <summary> /// Load a given MeshCluster into the scene. Only MeshClusters that are loaded take part in acoustic processing. /// </summary> public void LoadMeshCluster(SoundToolKitMeshCluster meshCluster) { if (meshCluster == null) { MeshClusters.Remove(meshCluster); return; } if (!meshCluster.AcousticMeshNames.Any()) { SoundToolKitDebug.LogWarning("Cannot load a MeshCluster that contains no SoundToolKitMeshes. " + "Please assign SoundToolKitMeshes to a cluster prior to loading it. (Trying to load " + meshCluster.name + " MeshCluster)"); return; } if (meshCluster.Model == null) { meshCluster.CreateInternalModel(); } SoundToolKitManager.Instance.StkAudioEngine.Scene.AddModel(meshCluster.Model); meshCluster.OnMeshesModified += ReloadMeshCluster; }