using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.ProjectWindowCallback;


namespace X2Engine
{
    class DoCreateDefaultFogConfig : EndNameEditAction
    {
        public override void Action(int instanceId, string pathName, string resourceFile)
        {
            var profile = DefaultFogConfigEditor.CreateDefaultFogConfigAtPath(pathName);
            ProjectWindowUtil.ShowCreatedAsset(profile);
        }
    }

    [CustomEditor(typeof(DefaultFogConfig))]
    public class DefaultFogConfigEditor : Editor
    {
        public static DefaultFogConfig CreateDefaultFogConfigAtPath(string path)
        {
            var profile = ScriptableObject.CreateInstance<DefaultFogConfig>();
            profile.name = Path.GetFileName(path);
            AssetDatabase.CreateAsset(profile, path);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            return profile;
        }

        [MenuItem("Assets/Create/Default Fog Config")]
        public static void CreateNewConfig()
        {
            ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance<DoCreateDefaultFogConfig>(), "DefaultFogConfig.asset", null, null);
        }
    }


}