private static void CreateCode()
    {
        var gameobject = Selection.gameObjects.First();

        if (!gameobject && !EditorUtility.IsPersistent(gameobject))
        {
            Debug.LogWarning("selection is not gameObject or not in scene!");
            return;
        }

        var scriptSavePath = gameobject.GetComponent <CodeGenerateInfo>().scriptSavePath;

        var scriptsFolder = Application.dataPath + "/" + scriptSavePath;

        if (!Directory.Exists(scriptsFolder))
        {
            Directory.CreateDirectory(scriptsFolder);
        }

        string className = ScriptName(gameobject.name);
        List <KeyValuePair <string, string> > cachePath = new List <KeyValuePair <string, string> >();

        SearchUIBind(gameobject.transform, cachePath);
        //利用注释的GUID 强制编译
        CodeTemplate.LogicWrite(scriptsFolder, ScriptName(gameobject.name));
        CodeTemplate.DesignerWrite(scriptsFolder, ScriptName(gameobject.name), cachePath);


        //确保难以出现两个
        //GameObjectUtility.RemoveMonoBehavioursWithMissingScript(gameobject);

        //因为脚本是动态创建的 所以需要刷新才会出现
        //但是刷新会重新编译 清空缓存
        EditorPrefs.SetString("GENERATE_CLASS_NAME", className);
        AssetDatabase.Refresh();
    }