void OnGUI()
    {
        EditorGUILayout.BeginVertical();

        EditorGUILayout.Separator();

        GUIStyle helpStyle = new GUIStyle(GUI.skin.label);
        helpStyle.wordWrap = true;
        helpStyle.alignment = TextAnchor.UpperLeft;
        EditorGUILayout.LabelField("This window can be use to create Puzzle Maker file that can be used to load puzzle maker class data from file, or you can save only puzzle pieces images created by puzzle maker", helpStyle);

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();

        _piecesInRow = EditorGUILayout.IntSlider("Pieces in row : ",_piecesInRow, 2, 10);

        _piecesInCol = EditorGUILayout.IntSlider("Pieces in col : ", _piecesInCol, 2, 10);

        _selectedTexture = (Texture2D)EditorGUILayout.ObjectField("Puzzle Image", _selectedTexture, typeof(Texture2D), false);

        EditorGUILayout.Separator();

        _noOfJointMasks = EditorGUILayout.IntField("Joints Mask Images", _noOfJointMasks);

        if (_pieceJointMaskImages.Length != _noOfJointMasks)
            _pieceJointMaskImages = new Texture2D[_noOfJointMasks];

        for ( int i=0; i<_noOfJointMasks; i++ )
            _pieceJointMaskImages[i] = (Texture2D)EditorGUILayout.ObjectField("Joint Mask Image " + (i+1).ToString(), 
                                            _pieceJointMaskImages[i], typeof(Texture2D), false);

        EditorGUILayout.Separator();



        _pmFileName = EditorGUILayout.TextField("Enter PM Filename" , _pmFileName);

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();



        if ( GUILayout.Button("Generate File", GUILayout.Height(45)) )
        {
            bool JointMaskNull = false;

            for (int i = 0; i < _pieceJointMaskImages.Length; i++)
            {
                if (_pieceJointMaskImages[i] == null)
                {
                    JointMaskNull = true;
                    break;
                }
            }


            if (JointMaskNull)
            {
                EditorUtility.DisplayDialog("Error", "You must select all Joint Mask Images", "OK");
            }
            else if (_selectedTexture == null)
            {
                EditorUtility.DisplayDialog("Error", "You must select puzzle image", "OK");
            }
            else
            {
                //string FilePath = EditorUtility.SaveFilePanel("Select file path", "c:\\", "PmFile.pm", "pm");

                if (!System.IO.Directory.Exists(Application.streamingAssetsPath))
                    System.IO.Directory.CreateDirectory(Application.streamingAssetsPath);

                if (_pmFileName == "" || _pmFileName.Length <= 3)
                {
                    EditorUtility.DisplayDialog("Filename Error", "Filename cannot be empty", "Let me change");
                }
                else
                {
                    Debug.Log(_pmFileName.Substring(_pmFileName.Length - 3, 3));

                    string FileName = _pmFileName.Substring(_pmFileName.Length - 3, 3) != ".pm" ?
                                                _pmFileName + ".pm" : _pmFileName;

                    //Check if file already exists
                    if (System.IO.File.Exists(Application.streamingAssetsPath + "/" + FileName))
                    {
                        EditorUtility.DisplayDialog("File creation error", "File with name" + FileName + " already exists", "Let me change");
                    }
                    else
                    {
                        try
                        {
                            PuzzlePieceMaker Temp = new PuzzlePieceMaker(_selectedTexture, _pieceJointMaskImages,
                                                                _piecesInRow, _piecesInCol);

                            Temp.SaveData(Application.streamingAssetsPath + "/" + FileName);

                            Debug.Log(FileName);

                            EditorUtility.DisplayDialog("Success", "File created succesfully", "Ok");
                            AssetDatabase.Refresh();
                        }
                        catch (UnityException ex)
                        {
                            EditorUtility.DisplayDialog("Failed", "File creation failed :" + ex.Message, "Ok");
                        }
                    }
                }

            }


        }
        

        EditorGUILayout.EndVertical();
    }