// Show Window
        //------------------------------------------------------------------
        public static void ShowDialog(apEditor editor, int parentX, int parentY)
        {
            CloseDialog();

            if (editor == null)
            {
                return;
            }


            EditorWindow curWindow             = EditorWindow.GetWindow(typeof(apDialog_AmbientCorrection), true, "Ambient Correction", true);
            apDialog_AmbientCorrection curTool = curWindow as apDialog_AmbientCorrection;

            //object loadKey = new object();
            if (curTool != null && curTool != s_window)
            {
                int width  = 540;
                int height = 430;
                s_window = curTool;
                int basePosX = parentX - 50;
                int basePosY = parentY + 50;
                //s_window.position = new Rect((editor.position.xMin + editor.position.xMax) / 2 - (width / 2),
                //								(editor.position.yMin + editor.position.yMax) / 2 - (height / 2),
                //								width, height);

                s_window.position = new Rect(Mathf.Max(basePosX - (width / 2), 10),
                                             Mathf.Max(basePosY - (height / 2), 10),
                                             width, height);

                s_window.Init(editor);
            }
        }
 public static void CloseDialog()
 {
     if (s_window != null)
     {
         try
         {
             s_window.Close();
         }
         catch (Exception ex)
         {
             Debug.LogError("Close Exception : " + ex);
         }
         s_window = null;
     }
 }