private void OnBecameVisible() { IsVisible = true; if (!Application.isPlaying) { return; } WaterYPosCacher.TryRegistrateController(getHash, null, this); }
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(); } }