コード例 #1
0
        public Error Create(IntPtr context)
        {
            var error = PhononCore.iplCreateProbeBatch(context, ref probeBatch);

            if (error != Error.None)
            {
                throw new Exception("Unable to create probe batch.");
            }

            error = PhononCore.iplCreateProbeManager(context, ref probeManager);
            if (error != Error.None)
            {
                throw new Exception("Unable to create probe batch.");
            }

            //Add all probes from all probe boxes to the probe batch.
            SteamAudioProbeBox[] allProbeBoxes = GameObject.FindObjectsOfType <SteamAudioProbeBox>() as SteamAudioProbeBox[];
            foreach (SteamAudioProbeBox probeBox in allProbeBoxes)
            {
                var probeBoxData = probeBox.LoadData();

                if (probeBoxData == null || probeBoxData.Length == 0)
                {
                    continue;
                }

                IntPtr probeBoxPtr = IntPtr.Zero;
                try
                {
                    PhononCore.iplLoadProbeBox(context, probeBoxData, probeBoxData.Length, ref probeBoxPtr);
                }
                catch (Exception e)
                {
                    Debug.LogError(e.Message);
                }

                int numProbes = PhononCore.iplGetProbeSpheres(probeBoxPtr, null);
                for (int i = 0; i < numProbes; ++i)
                {
                    PhononCore.iplAddProbeToBatch(probeBatch, probeBoxPtr, i);
                }

                PhononCore.iplDestroyProbeBox(ref probeBoxPtr);
            }

            //Add probe batch to probe manager.
            PhononCore.iplAddProbeBatch(probeManager, probeBatch);
            PhononCore.iplFinalizeProbeBatch(probeBatch);

            return(error);
        }