void InitReferences() { waterTrigger = waterVolume.GetComponent <BoxCollider>(); waterRenderer = waterVolume.GetComponent <Renderer>(); rippleCamera = GetComponent <Camera>(); waterBounds = waterRenderer.bounds; rippleTexture = new RenderTexture(1024, 1024, 16, RenderTextureFormat.ARGBHalf); rippleTexture.Create(); }
public override void OnInspectorGUI() { this.serializedObject.Update(); EditorGUI.BeginChangeCheck(); if (waterVolumeTarget.GetComponent <MeshFilter>().sharedMesh == null && !PrefabUtility.IsPartOfPrefabAsset(waterVolumeTarget)) { this.UpdateMesh(this.rows.intValue, this.columns.intValue, this.quadSegmentSize.floatValue); this.UpdateBoxCollider(this.rows.intValue, this.columns.intValue, this.quadSegmentSize.floatValue); } EditorGUILayout.PropertyField(this.rows); EditorGUILayout.PropertyField(this.columns); EditorGUILayout.PropertyField(this.quadSegmentSize); if (EditorGUI.EndChangeCheck()) { this.rows.intValue = Mathf.Max(1, this.rows.intValue); this.columns.intValue = Mathf.Max(1, this.columns.intValue); this.quadSegmentSize.floatValue = Mathf.Max(0f, this.quadSegmentSize.floatValue); this.UpdateMesh(this.rows.intValue, this.columns.intValue, this.quadSegmentSize.floatValue); this.UpdateBoxCollider(this.rows.intValue, this.columns.intValue, this.quadSegmentSize.floatValue); } this.serializedObject.ApplyModifiedProperties(); }
protected virtual void OnEnable() { this.waterVolumeTarget = (WaterVolume)this.target; this.rows = this.serializedObject.FindProperty("rows"); this.columns = this.serializedObject.FindProperty("columns"); this.quadSegmentSize = this.serializedObject.FindProperty("quadSegmentSize"); Undo.undoRedoPerformed += this.OnUndoRedoPerformed; waterVolumeTarget.GetComponent <MeshFilter>().hideFlags = HideFlags.NotEditable; waterVolumeTarget.GetComponent <BoxCollider>().hideFlags = HideFlags.NotEditable; waterVolumeTarget.GetComponent <BoxCollider>().isTrigger = true; waterVolumeTarget.GetComponent <BoxCollider>().enabled = waterVolumeTarget.enabled; if (Application.isPlaying && !PrefabUtility.IsPartOfPrefabAsset(waterVolumeTarget)) { waterVolumeTarget.GetComponent <Renderer>().material.hideFlags = HideFlags.NotEditable; } }