Exemple #1
0
        void OnDestroy()
        {
            if (isActive)
            {
                if (usePlanetShine)
                {
                    foreach (PlanetShineLight _aLight in celestialLightSources)
                    {
                        _aLight.OnDestroy();
                        UnityEngine.Object.Destroy(_aLight);
                    }
                }

                for (int i = 0; i < scattererCelestialBodies.Count; i++)
                {
                    ScattererCelestialBody cur = scattererCelestialBodies [i];
                    if (cur.active)
                    {
                        cur.m_manager.OnDestroy();
                        UnityEngine.Object.Destroy(cur.m_manager);
                        cur.m_manager = null;
//						ReactivateAtmosphere(cur.transformName,cur.originalPlanetMaterialBackup);
                        cur.active = false;
                    }
                }

                if (ambientLightScript)
                {
                    ambientLightScript.restoreLight();
                    Component.Destroy(ambientLightScript);
                }

                if (customDepthBuffer)
                {
                    customDepthBuffer.OnDestroy();
                    Component.Destroy(customDepthBuffer);
                    UnityEngine.Object.Destroy(customDepthBuffer);
                    customDepthBufferTexture.Release();
                    UnityEngine.Object.Destroy(customDepthBufferTexture);
                }

                if (refractionCam)
                {
                    refractionCam.OnDestroy();
                    Component.Destroy(refractionCam);
                    UnityEngine.Object.Destroy(refractionCam);
                    refractionTexture.Release();
                    UnityEngine.Object.Destroy(refractionTexture);
                }

                if (useGodrays)
                {
                    if (godrayDepthTexture)
                    {
                        if (godrayDepthTexture.IsCreated())
                        {
                            godrayDepthTexture.Release();
                        }
                        UnityEngine.Object.Destroy(godrayDepthTexture);
                    }
                }


                if (farCamera)
                {
                    if (nearCamera.gameObject.GetComponent(typeof(Wireframe)))
                    {
                        Component.Destroy(nearCamera.gameObject.GetComponent(typeof(Wireframe)));
                    }


                    if (farCamera.gameObject.GetComponent(typeof(Wireframe)))
                    {
                        Component.Destroy(farCamera.gameObject.GetComponent(typeof(Wireframe)));
                    }


                    if (scaledSpaceCamera.gameObject.GetComponent(typeof(Wireframe)))
                    {
                        Component.Destroy(scaledSpaceCamera.gameObject.GetComponent(typeof(Wireframe)));
                    }
                }


                if (fullLensFlareReplacement && customSunFlareAdded)
                {
                    foreach (SunFlare customSunFlare in customSunFlares)
                    {
                        customSunFlare.cleanUp();
                        Component.Destroy(customSunFlare);
                    }

                    //re-enable stock sun flares
                    global::SunFlare[] stockFlares = (global::SunFlare[])global::SunFlare.FindObjectsOfType(typeof(global::SunFlare));
                    foreach (global::SunFlare _flare in stockFlares)
                    {
                        if (sunflaresList.Contains(_flare.sun.name))
                        {
                            _flare.sunFlare.enabled = true;
                        }
                    }
                }

                inGameWindowLocation = new Vector2(windowRect.x, windowRect.y);
                saveSettings();
            }

            else if (mainMenu)
            {
                //replace EVE cloud shaders when leaving main menu to game
                if (integrateWithEVEClouds)
                {
                    ShaderReplacer.Instance.replaceEVEshaders();
                }

                mainMenuWindowLocation = new Vector2(windowRect.x, windowRect.y);
                saveSettings();
            }


            UnityEngine.Object.Destroy(GUItool);
        }
Exemple #2
0
        void OnDestroy()
        {
            if (isActive)
            {
                if (!ReferenceEquals(planetshineManager, null))
                {
                    planetshineManager.CleanUp();
                    Component.Destroy(planetshineManager);
                }

                if (!ReferenceEquals(scattererCelestialBodiesManager, null))
                {
                    scattererCelestialBodiesManager.Cleanup();
                }

                if (ambientLightScript)
                {
                    ambientLightScript.restoreLight();
                    Component.Destroy(ambientLightScript);
                }


                if (farCamera)
                {
                    if (nearCamera.gameObject.GetComponent(typeof(Wireframe)))
                    {
                        Component.Destroy(nearCamera.gameObject.GetComponent(typeof(Wireframe)));
                    }


                    if (farCamera.gameObject.GetComponent(typeof(Wireframe)))
                    {
                        Component.Destroy(farCamera.gameObject.GetComponent(typeof(Wireframe)));
                    }


                    if (scaledSpaceCamera.gameObject.GetComponent(typeof(Wireframe)))
                    {
                        Component.Destroy(scaledSpaceCamera.gameObject.GetComponent(typeof(Wireframe)));
                    }
                }


                if (!ReferenceEquals(sunflareManager, null))
                {
                    sunflareManager.Cleanup();
                    UnityEngine.Component.Destroy(sunflareManager);
                }

                if (!ReferenceEquals(sunlightModulatorInstance, null))
                {
                    sunlightModulatorInstance.OnDestroy();
                    Component.Destroy(sunlightModulatorInstance);
                }

//				if (shadowMaskModulate)
//				{
//					shadowMaskModulate.OnDestroy();
//					Component.Destroy(shadowMaskModulate);
//				}

                if (shadowFadeRemover)
                {
                    shadowFadeRemover.OnDestroy();
                    Component.Destroy(shadowFadeRemover);
                }

                if (farCameraShadowCascadeTweaker)
                {
                    Component.Destroy(farCameraShadowCascadeTweaker);
                }

                if (farDepthCommandbuffer)
                {
                    Component.Destroy(farDepthCommandbuffer);
                }

                if (nearDepthCommandbuffer)
                {
                    Component.Destroy(nearDepthCommandbuffer);
                }

                if (bufferManager)
                {
                    bufferManager.OnDestroy();
                    Component.Destroy(bufferManager);
                }

                pluginData.inGameWindowLocation = new Vector2(guiHandler.windowRect.x, guiHandler.windowRect.y);
                saveSettings();
            }

            UnityEngine.Object.Destroy(guiHandler);
        }