コード例 #1
0
        public static void EndBake()
        {
            if (sThread != null)
            {
                sThread.Join();
            }

            SerializedObject.FlushAllWrites();

#if (UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN)
            if (sProgressCallbackHandle.IsAllocated)
            {
                sProgressCallbackHandle.Free();
            }
#endif

            SteamAudioManager.ShutDown();
            UnityEngine.Object.DestroyImmediate(SteamAudioManager.Singleton.gameObject);

#if UNITY_EDITOR
            sProgress = 0.0f;
#endif
            sCurrentObjectIndex     = 0;
            sTotalObjects           = 0;
            sCurrentObjectName      = null;
            sCurrentProbeBatchIndex = 0;
            sTotalProbeBatches      = 0;

            sStatus = BakeStatus.Ready;

#if UNITY_EDITOR
            EditorApplication.update -= InEditorUpdate;
#endif
        }
コード例 #2
0
        public void DeleteBakedDataForIdentifier(BakedDataIdentifier identifier)
        {
            if (asset == null)
            {
                return;
            }

            SteamAudioManager.Initialize(ManagerInitReason.EditingProbes);

            var probeBatch = new ProbeBatch(SteamAudioManager.Context, asset);

            probeBatch.RemoveData(identifier);
            probeDataSize = probeBatch.Save(asset);

            SteamAudioManager.ShutDown();
            DestroyImmediate(SteamAudioManager.Singleton.gameObject);

            RemoveLayer(identifier);
        }
コード例 #3
0
        public void GenerateProbes()
        {
            SteamAudioManager.Initialize(ManagerInitReason.GeneratingProbes);
            SteamAudioManager.LoadScene(SceneManager.GetActiveScene(), SteamAudioManager.Context, false);
            var scene = SteamAudioManager.CurrentScene;

            SteamAudioStaticMesh staticMeshComponent = null;
            var rootObjects = SceneManager.GetActiveScene().GetRootGameObjects();

            foreach (var rootObject in rootObjects)
            {
                staticMeshComponent = rootObject.GetComponentInChildren <SteamAudioStaticMesh>();
                if (staticMeshComponent)
                {
                    break;
                }
            }

            if (staticMeshComponent == null || staticMeshComponent.asset == null)
            {
                Debug.LogError(string.Format("Scene {0} has not been exported. Click Steam Audio > Export Active Scene to do so.", SceneManager.GetActiveScene().name));
                return;
            }

            var staticMesh = new StaticMesh(SteamAudioManager.Context, scene, staticMeshComponent.asset);

            staticMesh.AddToScene(scene);

            scene.Commit();

            var probeArray = new ProbeArray(SteamAudioManager.Context);

            var probeGenerationParams = new ProbeGenerationParams {
            };

            probeGenerationParams.type      = placementStrategy;
            probeGenerationParams.spacing   = horizontalSpacing;
            probeGenerationParams.height    = heightAboveFloor;
            probeGenerationParams.transform = Common.TransposeMatrix(Common.ConvertTransform(gameObject.transform)); // Probe generation requires a transposed matrix.

            probeArray.GenerateProbes(scene, probeGenerationParams);

            var numProbes = probeArray.GetNumProbes();

            mProbeSpheres = new Sphere[numProbes];
            for (var i = 0; i < numProbes; ++i)
            {
                mProbeSpheres[i] = probeArray.GetProbe(i);
            }

            var probeBatch = new ProbeBatch(SteamAudioManager.Context);

            probeBatch.AddProbeArray(probeArray);

            probeDataSize = probeBatch.Save(GetAsset());

            probeBatch.Release();
            probeArray.Release();
            staticMesh.Release();

            SteamAudioManager.ShutDown();
            DestroyImmediate(SteamAudioManager.Singleton.gameObject);

            ResetLayers();

            Debug.Log("Generated " + mProbeSpheres.Length + " probes for game object " + gameObject.name + ".");

            // Redraw scene view for probes to show up instantly.
#if UNITY_EDITOR
            SceneView.RepaintAll();
#endif
        }