private void LateUpdate() { wasStaticUpdate = false; if (need_update) { #if FASTWATER20_LOG Debug.Log("local_update"); #endif need_update = false; } if (local_update) { #if UNITY_EDITOR TryCreateTempMaterials(); #endif setter_cache.Clear(); RenderOnAwake(); local_update = false; #if UNITY_EDITOR // if (!Application.isPlaying) { WaterYPosCacher.CLEAR_ALL(); CalcVertexSize(); } #endif } }
private void OnBecameVisible() { IsVisible = true; if (!Application.isPlaying) { return; } WaterYPosCacher.TryRegistrateController(getHash, null, this); }
public static void undoRedoPerfowrm() { if (!mainThread.Equals(System.Threading.Thread.CurrentThread)) { return; } #if FASTWATER20_LOG Debug.Log("undoRedoPerfowrm"); #endif foreach (var list in editor_cache_matcollector) { foreach (var item in list.Value) { if (item) { if (Application.isPlaying) {/*Destroy(item);*/ } else { DestroyImmediate(item); } } } list.Value.Clear(); } var resList = editor_cache_materials.Keys.ToArray(); foreach (var list in editor_cache_gocollector) { foreach (var item in list.Value) { if (item) { editor_cache_materials.Remove(item.goID); } } list.Value.Clear(); } WaterYPosCacher.CLEAR_ALL(); foreach (var item in resList) { if (id_to_controller.ContainsKey(item) && id_to_controller[item]) { id_to_controller[item].TryCreateTempMaterials(); } } // Debug.Log( UnityEditor.Undo.() ); }
private void OnEnable() { if (!this || !enabled) { return; } // if (_was_enables) return; _was_enables = true; __this = this; if (!__goID.HasValue) { __goID = gameObject.GetInstanceID(); } #if FASTWATER20_LOG Debug.Log("OnEnable " + gameObject.name); #endif #if UNITY_EDITOR if (mainThread == null) { mainThread = System.Threading.Thread.CurrentThread; } // if (!mainThread.Equals(System.Threading.Thread.CurrentThread)) return; if (!id_to_controller.ContainsKey(goID)) { id_to_controller.Add(goID, this); } else { id_to_controller[goID] = this; } need_update = true; // DidReload(); #endif if (!__renderer) { __renderer = GetComponent <MeshRenderer>(); } if (__compiler) { __compiler.onShaderUpdate -= onShaderUpdate; __compiler.onShaderUpdate += onShaderUpdate; if (!__compiler.__cID.HasValue) { __compiler.__cID = GetInstanceID(); } if (__renderer) { __renderer.receiveShadows = __compiler.IsKeywordEnabled("USE_SHADOWS"); } } #if UNITY_EDITOR TryCreateTempMaterials(); EditorApplication.update -= EditorUpdate; EditorApplication.update += EditorUpdate; EditorApplication.update -= static_Update; EditorApplication.update += static_Update; EditorApplication.playModeStateChanged -= onPlayModeChange; EditorApplication.playModeStateChanged += onPlayModeChange; OnEnable2(); #endif Camera.onPostRender -= OnPostRenderMy; Camera.onPostRender += OnPostRenderMy; Camera.onPreRender -= OnPreRenderMy; Camera.onPreRender += OnPreRenderMy; WaterYPosCacher.TryRegistrateController(getHash, null, this); #if DEBUG_BAKED_TEXTURE lastTarget = this; SceneView.onSceneGUIDelegate -= sv; SceneView.onSceneGUIDelegate += sv; #endif #if UNITY_EDITOR UnityEditor.Undo.undoRedoPerformed -= Reset; UnityEditor.Undo.undoRedoPerformed += Reset; UnityEditor.Undo.undoRedoPerformed -= RepantInspector; UnityEditor.Undo.undoRedoPerformed += RepantInspector; UnityEditor.Undo.undoRedoPerformed -= undoRedoPerfowrm; UnityEditor.Undo.undoRedoPerformed += undoRedoPerfowrm; #endif CalcVertexSize(); if (!DirectionLight) { var light = GameObject.FindObjectOfType <Light>(); if (light) { DirectionLight = light.transform; } else { DirectionLight = null; } #if UNITY_EDITOR SetDirty(this); #endif } /* if (!compiler) * { * if (RENDERER) compiler = RE_NDERER.sharedMaterial; * else compiler = null; * }*/ Reset(); if (MESH) { CurrentMeshData = GET_MESH(MESH.sharedMesh); } //if (Application.isPlaying && wasAwake) RenderOnAwake(); if (Application.isPlaying && wasAwake) { Start(); } }