private void OnGUI() { InitStyles(); ComputeMeshPaintWaterPipe waterSimulation = FindObjectOfType <ComputeMeshPaintWaterPipe>(); if (waterSimulation != null) { GUILayout.Label("Pipe water simulation script found! (" + waterSimulation.name + ")", titleStyle); // Draw Flux DrawFlux(waterSimulation); // Draw water and terrain texture DrawWaterTerrainVelocity(waterSimulation); if (!EditorApplication.isPlaying) { GUILayout.Label("The render textures are only shown in Play-Mode!"); } } else { GUILayout.Label("No Pipe model script found! You made everything wrong! :D", titleStyle); } }
private void DrawFlux(ComputeMeshPaintWaterPipe waterSimulation) { float size = EditorGUIUtility.currentViewWidth / 4.3f; EditorGUILayout.BeginHorizontal(); ShowImage("Flux Left:", waterSimulation.FluxLeft, size, size); ShowImage("Flux Right:", waterSimulation.FluxRight, size, size); ShowImage("Flux Top:", waterSimulation.FluxTop, size, size); ShowImage("Flux Bottom:", waterSimulation.FluxBottom, size, size); EditorGUILayout.EndHorizontal(); }
private void DrawWaterTerrainVelocity(ComputeMeshPaintWaterPipe waterSimulation) { float size = EditorGUIUtility.currentViewWidth / 4.3f; EditorGUILayout.BeginHorizontal(); ShowImage("Water:", waterSimulation.WaterHeight, size, size); ShowImage("Terrain:", waterSimulation.TerrainHeight, size, size); ShowImage("Velocity X:", waterSimulation.VelocityX, size, size); ShowImage("Velocity Y:", waterSimulation.VelocityY, size, size); EditorGUILayout.EndHorizontal(); }
private void Initialize() { waterPipeSimulation = FindObjectOfType <ComputeMeshPaintWaterPipe>(); if (waterPipeSimulation == null) { Debug.LogError("Water sources only work in combination with ComputeMeshPaintWaterPipe script! Check if this script is in the scene."); } collisionLayer = LayerMask.NameToLayer(collisionLayerName); // Register at the water simulation waterPipeSimulation.AddWaterSource(this); }
protected override void Start() { pipeSimulation = FindObjectOfType <ComputeMeshPaintWaterPipe>(); terrainSimulation = FindObjectOfType <ComputeHeightmapPainter>(); if (pipeSimulation == null) { Debug.LogError("No water simulation in scene!"); } if (terrainSimulation == null) { Debug.LogError("No terrain simulation in scene!"); } base.Start(); }