public override void OnInspectorGUI()
    {
        //put check to make sure you're putting surfacenoise on the parent GO.
        if (isValidHierarchy(Selection.gameObjects[0]))
        {
            QT_SurfaceNoise SN   = (QT_SurfaceNoise)target;
            bool            isMM = isMultiMesh(Selection.gameObjects[0]);

            if (isMM && SN.enableMultiMesh == false)
            {
                EditorGUILayout.HelpBox("Varied Meshes or PolyWorld Terrain Detected.\n\nMultiMesh flag should be enabled to prevent errors. This will be more costly to calculate. See Help for important information.", MessageType.Warning);
            }
            else if (isMM == false && SN.enableMultiMesh == true)
            {
                EditorGUILayout.HelpBox("No Varied Meshes or PolyWorld Terrain detected.\n\nMutiMesh flag could be disabled for performance increase.", MessageType.Info);
            }

            SN.useOverride = true;// EditorGUILayout.Toggle("Preset Override", SN.useOverride);
            if (SN.useOverride == false)
            {
                is2mPlane = CheckPlaneSize(Selection.gameObjects[0]);

                if (is2mPlane)
                {
                    P2 = (Plane2m)EditorGUILayout.EnumPopup("Wave Preset:", P2);
                }
                else
                {
                    P10 = (Plane10m)EditorGUILayout.EnumPopup("Wave Type:", P10);
                }
                SN.waveScale = SetWaveScale();
            }
            else
            {
                SN.waveScale = EditorGUILayout.Slider("Wave Shape", SN.waveScale, 0.1f, 1f);
            }

            // SN.enableDebug = EditorGUILayout.Toggle("enable debug", SN.enableDebug);
            // SN.scaleMultiplier = EditorGUILayout.IntSlider(SN.scaleMultiplier, 1, 20);
            // SN.waveOffset = EditorGUILayout.Slider(SN.waveOffset, 0f, 6f);
            SN.speedMultiplier    = EditorGUILayout.Slider("Wave Speed", SN.speedMultiplier, 1, 400);
            SN.strengthMultiplier = EditorGUILayout.Slider("Wave Height", SN.strengthMultiplier, 0, 10);
            SN.RecalculateNormals = EditorGUILayout.Toggle("Recalculate Normals", SN.RecalculateNormals);
            SN.useVertexAlpha     = EditorGUILayout.Toggle("Use Vertex Alpha", SN.useVertexAlpha);
            SN.XAxis           = EditorGUILayout.Toggle("X Axis", SN.XAxis);
            SN.YAxis           = EditorGUILayout.Toggle("Y Axis", SN.YAxis);
            SN.ZAxis           = EditorGUILayout.Toggle("Z Axis", SN.ZAxis);
            SN.enableMultiMesh = EditorGUILayout.Toggle("Enable Multimesh", SN.enableMultiMesh);
            if (SN.enableMultiMesh)
            {
                SN.enableOffset = EditorGUILayout.Toggle("Unique Offset", SN.enableOffset);
            }
            SN.enableLOD = EditorGUILayout.Toggle("Enable LOD", SN.enableLOD);
            if (SN.enableLOD)
            {
                SN.TargetCamera = (Camera)EditorGUILayout.ObjectField("Camera: ", SN.TargetCamera, typeof(Camera), true, null);
                if (!SN.TargetCamera)
                {
                    EditorGUILayout.HelpBox("No Camera Assigned! LOD can't run.", MessageType.Error);
                }
                SN.LODDistance     = EditorGUILayout.IntSlider("Distance:", SN.LODDistance, 5, 100);
                SN.showDebugSphere = EditorGUILayout.Toggle("Visualize Distance:", SN.showDebugSphere);
                if (SN.showDebugSphere)
                {
                    if (debugSphere == null)
                    {
                        debugSphere      = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                        debugSphere.name = "#DebugSphere - Delete Me";
                    }
                    else
                    {
                        debugSphere.transform.localPosition = Selection.activeGameObject.transform.localPosition;
                        //debugSphere.transform.position = Selection.activeGameObject.transform.position;
                        debugSphere.transform.localScale = new Vector3(SN.LODDistance, SN.LODDistance, SN.LODDistance);
                    }
                }
                else
                {
                    if (debugSphere)
                    {
                        DestroyImmediate(debugSphere);
                    }
                }
            }
            if (GUILayout.Button("Help"))
            {
                Application.OpenURL("http://qt-ent.com/PolyWorld/scripts/");
            }
        }
        else
        {
            EditorGUILayout.HelpBox("No valid children found. Noise is only applied to children of a parent Game Object.\n\nLink some gameobjects with MeshFilter components to an empty Game Object. SkinnedMeshes are not supported yet.", MessageType.Error);
        }
    }
    public override void OnInspectorGUI()
    {
        //put check to make sure you're putting surfacenoise on the parent GO.
        if (isValidHierarchy(Selection.gameObjects[0]))
        {
            QT_SurfaceNoise SN = (QT_SurfaceNoise)target;
            bool isMM = isMultiMesh(Selection.gameObjects[0]);

            if (isMM && SN.enableMultiMesh == false)
                EditorGUILayout.HelpBox("Varied Meshes or PolyWorld Terrain Detected.\n\nMultiMesh flag should be enabled to prevent errors. This will be more costly to calculate. See Help for important information.", MessageType.Warning);
            else if (isMM == false && SN.enableMultiMesh == true)
                EditorGUILayout.HelpBox("No Varied Meshes or PolyWorld Terrain detected.\n\nMutiMesh flag could be disabled for performance increase.", MessageType.Info);

            SN.useOverride = EditorGUILayout.Toggle("Preset Override", SN.useOverride);
            if (SN.useOverride == false)
            {
                is2mPlane = CheckPlaneSize(Selection.gameObjects[0]);

                if (is2mPlane)
                    P2 = (Plane2m)EditorGUILayout.EnumPopup("Wave Preset:", P2);
                else
                    P10 = (Plane10m)EditorGUILayout.EnumPopup("Wave Type:", P10);
                SN.waveScale = SetWaveScale();
            }
            else
                SN.waveScale = EditorGUILayout.Slider("Wave Shape", SN.waveScale, 0.1f, 50);

           // SN.enableDebug = EditorGUILayout.Toggle("enable debug", SN.enableDebug);
           // SN.scaleMultiplier = EditorGUILayout.IntSlider(SN.scaleMultiplier, 1, 20);
           // SN.waveOffset = EditorGUILayout.Slider(SN.waveOffset, 0f, 6f);
            SN.speedMultiplier = EditorGUILayout.Slider("Wave Speed", SN.speedMultiplier, 1, 400);
            SN.strengthMultiplier = EditorGUILayout.Slider("Wave Height", SN.strengthMultiplier, 0, 10);
            SN.RecalculateNormals = EditorGUILayout.Toggle("Recalculate Normals", SN.RecalculateNormals);
            SN.useVertexAlpha = EditorGUILayout.Toggle("Use Vertex Alpha", SN.useVertexAlpha);
            SN.XAxis = EditorGUILayout.Toggle("X Axis", SN.XAxis);
            SN.YAxis = EditorGUILayout.Toggle("Y Axis", SN.YAxis);
            SN.ZAxis = EditorGUILayout.Toggle("Z Axis", SN.ZAxis);
            SN.enableMultiMesh = EditorGUILayout.Toggle("Enable Multimesh", SN.enableMultiMesh);
            if (SN.enableMultiMesh)
                SN.enableOffset = EditorGUILayout.Toggle("Unique Offset", SN.enableOffset);
            SN.enableLOD = EditorGUILayout.Toggle("Enable LOD", SN.enableLOD);
            if (SN.enableLOD)
            {
                if(!Camera.main)
                    EditorGUILayout.HelpBox("No Main Camera Found! LOD can't run.",MessageType.Error);
                SN.LODDistance = EditorGUILayout.IntSlider("Distance:", SN.LODDistance,5,100);
                SN.showDebugSphere = EditorGUILayout.Toggle("Visualize Distance:",SN.showDebugSphere);
                if(SN.showDebugSphere)
                {
                    if(debugSphere==null)
                    {
                        debugSphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                        debugSphere.name = "#DebugSphere - Delete Me";
                    }
                    else
                    {
                        debugSphere.transform.localPosition = Selection.activeGameObject.transform.localPosition;
                        //debugSphere.transform.position = Selection.activeGameObject.transform.position;
                        debugSphere.transform.localScale = new Vector3(SN.LODDistance,SN.LODDistance,SN.LODDistance);
                    }
                }
                else
                {
                    if(debugSphere)
                        DestroyImmediate(debugSphere);
                }

            }
            if (GUILayout.Button("Help"))
            {
                Application.OpenURL("http://qt-ent.com/PolyWorld/scripts/");
            }
        }
        else
            EditorGUILayout.HelpBox("No valid children found. Noise is only applied to children of a parent Game Object.\n\nLink some gameobjects with MeshFilter components to an empty Game Object. SkinnedMeshes are not supported yet.", MessageType.Error);
    }