Esempio n. 1
0
        public void BeginBake(GameObject[] gameObjects, BakingMode[] bakingModes, string[] stringIdentifiers,
                              Sphere[] influenceSpheres, ProbeBox[][] probeBoxes)
        {
            oneBakeActive         = true;
            bakeStatus            = BakeStatus.InProgress;
            duringBakeObjects     = gameObjects;
            duringBakeProbeBoxes  = probeBoxes;
            duringBakeModes       = bakingModes;
            duringBakeIdentifiers = stringIdentifiers;
            duringBakeSpheres     = influenceSpheres;

            for (int i = 0; i < gameObjects.Length; ++i)
            {
                if (stringIdentifiers[i].Length == 0 && bakingModes[i] != BakingMode.Reverb)
                {
                    Debug.LogError("Unique identifier not specified for GameObject " + gameObjects[i].name);
                }
            }

            // Initialize environment
            try
            {
                duringBakePhononManager = GameObject.FindObjectOfType <PhononManager>();
                if (duringBakePhononManager == null)
                {
                    throw new Exception("Phonon Manager Settings object not found in the scene! Click Window > Phonon");
                }

                bool initializeRenderer = false;
                duringBakePhononManager.Initialize(initializeRenderer);
                duringBakePhononContainer = duringBakePhononManager.PhononManagerContainer();
                duringBakePhononContainer.Initialize(initializeRenderer, duringBakePhononManager);

                if (duringBakePhononContainer.Scene().GetScene() == IntPtr.Zero)
                {
                    throw new Exception("Make sure to pre-export the scene before baking.");
                }
            }
            catch (Exception e)
            {
                bakeStatus = BakeStatus.Complete;
                Debug.LogError(e.Message);
                return;
            }

            bakeCallback = new PhononCore.BakeProgressCallback(AdvanceProgress);

#if (UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN)
            bakeCallbackPointer = Marshal.GetFunctionPointerForDelegate(bakeCallback);
            bakeCallbackHandle  = GCHandle.Alloc(bakeCallbackPointer);
            GC.Collect();
#endif

#if UNITY_EDITOR
            EditorApplication.update += InEditorUpdate;
#endif

            bakeThread = new Thread(new ThreadStart(BakeEffectThread));
            bakeThread.Start();
        }
Esempio n. 2
0
        public void BeginBake(ProbeBox[] probeBoxes, BakingMode bakingMode, string identifier = default(string),
                              Sphere sphere = default(Sphere))
        {
            oneBakeActive        = true;
            bakeStatus           = BakeStatus.InProgress;
            duringBakeProbeBoxes = probeBoxes;
            duringBakeMode       = bakingMode;
            duringBakeIdentifier = identifier;
            duringBakeSphere     = sphere;

#if UNITY_EDITOR
            totalProbeBoxes = duringBakeProbeBoxes.Length;
#endif

            if (probeBoxes.Length == 0)
            {
                Debug.LogError("Probe Box component not attached or no probe boxes selected for baking.");
            }

            // Initialize environment
            try
            {
                duringBakePhononManager = GameObject.FindObjectOfType <PhononManager>();
                if (duringBakePhononManager == null)
                {
                    throw new Exception("Phonon Manager Settings object not found in the scene! Click Window > Phonon");
                }

                bool initializeRenderer = false;
                duringBakePhononManager.Initialize(initializeRenderer);
                duringBakePhononContainer = duringBakePhononManager.PhononManagerContainer();
                duringBakePhononContainer.Initialize(initializeRenderer, duringBakePhononManager);

                if (duringBakePhononContainer.Scene().GetScene() == IntPtr.Zero)
                {
                    throw new Exception("Make sure to pre-export the scene before baking.");
                }
            }
            catch (Exception e)
            {
                bakeStatus = BakeStatus.Complete;
                Debug.LogError(e.Message);
                return;
            }

            bakeCallback = new PhononCore.BakeProgressCallback(AdvanceProgress);

#if (UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN)
            bakeCallbackPointer = Marshal.GetFunctionPointerForDelegate(bakeCallback);
            bakeCallbackHandle  = GCHandle.Alloc(bakeCallbackPointer);
            GC.Collect();
#endif

            bakeThread = new Thread(new ThreadStart(BakeEffectThread));
            bakeThread.Start();
        }
Esempio n. 3
0
        public void BeginBake()
        {
            bakeStatus = BakeStatus.InProgress;

            duringBakeProbeBoxes = probeBoxes;
            if (useAllProbeBoxes)
            {
                duringBakeProbeBoxes = FindObjectsOfType <ProbeBox>() as ProbeBox[];
            }

            totalProbeBoxes = duringBakeProbeBoxes.Length;

            // Initialize environment
            try
            {
                duringBakeEnvComponent = FindObjectOfType <EnvironmentComponent>();
                if (duringBakeEnvComponent == null)
                {
                    throw new Exception("Environment Component not found. Add one to the scene");
                }

                bool initializeRenderer = false;
                duringBakeEnvComponent.Initialize(initializeRenderer);
            }
            catch (Exception e)
            {
                bakeStatus = BakeStatus.Complete;
                Debug.LogError(e.Message);
                return;
            }

            var bakeSphereCenter = Common.ConvertVector(gameObject.transform.position);

            duringBakeSphere.centerx = bakeSphereCenter.x;
            duringBakeSphere.centery = bakeSphereCenter.y;
            duringBakeSphere.centerz = bakeSphereCenter.z;
            duringBakeSphere.radius  = bakingRadius;

            bakeCallback = new PhononCore.BakeProgressCallback(AdvanceProgress);

                        #if (UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN)
            bakeCallbackPointer = Marshal.GetFunctionPointerForDelegate(bakeCallback);
            bakeCallbackHandle  = GCHandle.Alloc(bakeCallbackPointer);
            GC.Collect();
                        #endif

            bakeThread = new Thread(new ThreadStart(BakeEffectThread));
            bakeThread.Start();
        }
Esempio n. 4
0
        public void BeginBake(GameObject[] gameObjects, BakedDataIdentifier[] identifiers, string[] names, Sphere[] influenceSpheres,
                              SteamAudioProbeBox[][] probeBoxes)
        {
            duringBakeObjects     = gameObjects;
            duringBakeProbeBoxes  = probeBoxes;
            duringBakeIdentifiers = identifiers;
            duringBakeNames       = names;
            duringBakeSpheres     = influenceSpheres;

            duringBakeObjectNames = new string[duringBakeObjects.Length];
            for (var i = 0; i < duringBakeObjects.Length; ++i)
            {
                duringBakeObjectNames[i] = names[i];
            }

            for (int i = 0; i < gameObjects.Length; ++i)
            {
                if (identifiers[i].identifier == 0 && identifiers[i].type != BakedDataType.Reverb)
                {
                    Debug.LogError("Unique identifier not specified for GameObject " + gameObjects[i].name);
                }
            }

            // Initialize environment
            try
            {
                steamAudioManager = GameObject.FindObjectOfType <SteamAudioManager>();
                if (steamAudioManager == null)
                {
                    throw new Exception("Phonon Manager Settings object not found in the scene! Click Window > Phonon");
                }

                steamAudioManager.Initialize(GameEngineStateInitReason.Baking);

                if (steamAudioManager.GameEngineState().Scene().GetScene() == IntPtr.Zero)
                {
                    throw new Exception("Make sure to pre-export the scene before baking.");
                }
            }
            catch (Exception e)
            {
                bakeStatus = BakeStatus.Complete;
                Debug.LogError(e.Message);
                return;
            }

            oneBakeActive = true;
            bakeStatus    = BakeStatus.InProgress;

            foreach (var probeBoxArray in duringBakeProbeBoxes)
            {
                foreach (var probeBox in probeBoxArray)
                {
                    probeBox.CacheFileName();
                }
            }

            bakeCallback = new PhononCore.BakeProgressCallback(AdvanceProgress);

#if (UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN)
            bakeCallbackPointer = Marshal.GetFunctionPointerForDelegate(bakeCallback);
            bakeCallbackHandle  = GCHandle.Alloc(bakeCallbackPointer);
            GC.Collect();
#endif

#if UNITY_EDITOR
            EditorApplication.update += InEditorUpdate;
#endif

            bakeThread = new Thread(new ThreadStart(BakeEffectThread));
            bakeThread.Start();
        }