示例#1
0
        private void DrawTilableMeshGUI()
        {
            if (!isEditingTileIndices)
            {
                EditorGUI.BeginChangeCheck();
                //water.MeshType = (PWaterMeshType)EditorGUILayout.EnumPopup("Mesh Type", water.MeshType);
                water.MeshType       = (PWaterMeshType)EditorGUILayout.IntPopup("Mesh Type", (int)water.MeshType, meshTypeLabels, meshTypes);
                water.PlanePattern   = (PPlaneMeshPattern)EditorGUILayout.EnumPopup("Pattern", water.PlanePattern);
                water.MeshResolution = EditorGUILayout.DelayedIntField("Resolution", water.MeshResolution);
                if (EditorGUI.EndChangeCheck())
                {
                    water.GenerateMesh();
                    water.ReCalculateBounds();
                }
                water.MeshNoise = EditorGUILayout.FloatField("Noise", water.MeshNoise);

                EditorGUI.BeginChangeCheck();
                water.TileSize = PEditorCommon.InlineVector2Field("Tile Size", water.TileSize);
                water.TilesFollowMainCamera = EditorGUILayout.Toggle("Follow Main Camera", water.TilesFollowMainCamera);
                SerializedObject   so = new SerializedObject(water);
                SerializedProperty sp = so.FindProperty("tileIndices");

                if (sp != null)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(sp, true);
                    if (EditorGUI.EndChangeCheck())
                    {
                        so.ApplyModifiedProperties();
                    }
                }

                sp.Dispose();
                so.Dispose();

                if (EditorGUI.EndChangeCheck())
                {
                    water.ReCalculateBounds();
                }
            }

            if (!isEditingTileIndices)
            {
                if (GUILayout.Button("Edit Tiles"))
                {
                    isEditingTileIndices = true;
                }
            }
            else
            {
                EditorGUILayout.LabelField("Edit water tiles in Scene View.", PEditorCommon.WordWrapItalicLabel);
                if (GUILayout.Button("End Editing Tiles"))
                {
                    isEditingTileIndices = false;
                }
            }
        }
        private static void DrawWaterConfigGUI(PWater water)
        {
            DrawTemplateSelectionGUI(water);

            PWaterQuickSetupConfig config = PWaterQuickSetupConfig.Instance;
            bool changed     = false;
            bool meshChanged = false;

            EditorGUI.BeginChangeCheck();
            config.WaterLevel = EditorGUILayout.FloatField("Water Level", config.WaterLevel);
            if (EditorGUI.EndChangeCheck())
            {
                changed = true;
            }

            EditorGUI.BeginChangeCheck();
            config.MeshResolution = EditorGUILayout.DelayedIntField("Resolution", config.MeshResolution);
            if (EditorGUI.EndChangeCheck())
            {
                meshChanged = true;
            }

            EditorGUI.BeginChangeCheck();
            config.MeshNoise        = EditorGUILayout.FloatField("Noise", config.MeshNoise);
            config.ApproximateSizeX = EditorGUILayout.FloatField("Approx. Size X", config.ApproximateSizeX);
            config.ApproximateSizeZ = EditorGUILayout.FloatField("Approx. Size Z", config.ApproximateSizeZ);
            config.TileSize         = PEditorCommon.InlineVector2Field("Tile Size", config.TileSize);
            if (EditorGUI.EndChangeCheck())
            {
                changed = true;
            }

            if (meshChanged)
            {
                water.GeneratePlaneMesh();
            }

            if (changed || meshChanged)
            {
                water.MeshNoise = config.MeshNoise;
                water.TileSize  = config.TileSize;
                water.UpdateMaterial();
                MatchWaterLevel(water);
                MatchWaterSize(water);
            }

            EditorUtility.SetDirty(config);

            GEditorCommon.Separator();
            if (GUILayout.Button("Center To Level Bounds"))
            {
                CenterToLevel(water);
            }
            if (GUILayout.Button("Fill Level Bounds"))
            {
                Bounds levelBounds = GCommon.GetLevelBounds();
                config.ApproximateSizeX = levelBounds.size.x;
                config.ApproximateSizeZ = levelBounds.size.z;
                CenterToLevel(water);
                MatchWaterSize(water);
            }
            if (GUILayout.Button("Done"))
            {
                Done(water);
            }
        }