#pragma warning restore void OnDisable() { if (!this || !enabled) { return; } if (OnDisableAction != null) { OnDisableAction(getHash, lastPlanarReflectionSize, this); } FastWaterModel20FrameBuffer.DestroyAllScript(); #if UNITY_EDITOR // if (!mainThread.Equals(System.Threading.Thread.CurrentThread)) return; /* if (!Applicati on.isPlaying) * { if (!initFlag) * { initFlag = true;*/ // if (!Application.isPlaying) DestroyAllEditorDatasDeep(); /* } * }*/ #endif // if (gameObject.activeSelf) return; _was_enables = false; if (__compiler) { __compiler.onShaderUpdate -= onShaderUpdate; } #if FASTWATER20_LOG Debug.Log("OnDisable " + gameObject.name); #endif #if UNITY_EDITOR OnDisable2(); EditorApplication.update -= EditorUpdate; // RestoreMat(); #endif Camera.onPostRender -= OnPostRenderMy; Camera.onPreRender -= OnPreRenderMy; if (RenderDepthOrRefractionCamera) { DESTROY_CAMERA(RenderDepthOrRefractionCamera); } if (RenderReflectionCamera) { DESTROY_CAMERA(RenderReflectionCamera); } destroyHelper.Push(goID); if (__compiler) { /* if (cache_GET_RENDER_TEXTURE.ContainsKey(goID)) * { * * foreach (var itemList in cache_GET_RENDER_TEXTURE[goID]) * { foreach (var item in itemList.Value) * { if (item == null) * continue; * if (item.lastCamera) * item.lastCamera.targetTexture = null; * if (item.texture_swap) * DESTORY(item.texture_swap); * if (item.texture_gles20) * DESTORY(item.texture_gles20); * } * itemList.Value.Clear(); * // item.Value.lastCamera * } * }*/ /* #if UNITY_EDITOR * if (editor_cache_materials.ContainsKey(goID)) * { //Debug.Log("ASD"); * if (editor_cache_materials[goID]) * { Destroy(editor_cache_materials[goID].GetTexture(_ReflectionTex_temp), 5); * Destroy(editor_cache_materials[goID].GetTexture(_RefractionTex_temp), 5); * Destroy(editor_cache_materials[goID].GetTexture(_BakedData_temp), 5); * // DESTORY(editor_cache_materials[goID].GetTexture(_ReflectionTex_temp)); * // DESTORY(editor_cache_materials[goID].GetTexture(_RefractionTex_temp)); * // DESTORY(editor_cache_materials[goID].GetTexture(_BakedData_temp)); * / * var t1 = editor_cache_materials[goID].GetTexture(_ReflectionTex_temp) as RenderTexture; * if (t1) t1.DiscardContents(true, true); * if (t1) t1.Release(); * var t2 = editor_cache_materials[goID].GetTexture(_RefractionTex_temp) as RenderTexture; * if (t2) t2.DiscardContents(true, true); * if (t2) t1.Release(); * var t3 = editor_cache_materials[goID].GetTexture(_BakedData_temp) as RenderTexture; * if (t3) t3.DiscardContents(true, true); * if (t3) t1.Release();* / * * //Unity 2018.2f14 crashed when scene was changing and had paticles emmiter * // if (!Application.isPlaying) DESTORY(editor_cache_materials[goID]); * //Unity 2018.2f14 crashed when scene was changing and had paticles emmiter * } * editor_cache_materials.Remove(goID); * } #else * DESTORY(__compiler.material.GetTexture(_ReflectionTex_temp)); * DESTORY(__compiler.material.GetTexture(_RefractionTex_temp)); * DESTORY(__compiler.material.GetTexture(_BakedData_temp)); #endif*/ } //Unity 2018.2f14 crashed when scene was changing and had paticles emmiter /* DESTORY(DepthRenderShader_SecondPass_Matertial); * if (__renderer && __renderer.sharedMaterial && (__renderer.sharedMaterial.hideFlags & HideFlags.HideAndDontSave) != 0) * DESTORY(__renderer.sharedMaterial);*/ //Unity 2018.2f14 crashed when scene was changing and had paticles emmiter }