private Texture GetTextureByName(string name)
        {
            if (!init)
            {
                init = true;

                LoadIconDelegate loadIcon = new InternalGetter <LoadIconDelegate>(typeof(EditorGUIUtility), "LoadIcon").Func;

                foreach (var icon in important)
                {
                    var t = loadIcon(icon);
                    icons.Add(icon, t);
                }
            }

            Texture tex;

            icons.TryGetValue(name, out tex);
            return(tex);
        }
        private static void AddScriptTemplate(string name, int priority, string file, string template, Entry parent = null, Type createdType = null)
        {
#if !UNITY_2019_1_OR_NEWER
            CreateScriptAsset createScriptAsset =
                new InternalGetter <CreateScriptAsset>(typeof(ProjectWindowUtil), "CreateScriptAsset").Func;
#endif
            var entry = new Entry(name, () =>
            {
#if UNITY_2019_1_OR_NEWER
                ProjectWindowUtil.CreateScriptAssetFromTemplateFile(template, file);
#else
                createScriptAsset(template, file);
#endif
            }, () => true, parent, priority, createdType);

            if (parent == null)
            {
                entries.Add(entry);
            }
            else
            {
                parent.Children.Add(entry);
            }
        }
        /// <summary>
        /// Those items are added by Unity native code, so we cannot detect them automatically. Therefore we recreate them.
        /// </summary>
        private static void AddInternals()
        {
            entries.Add(new Entry("Folder", ProjectWindowUtil.CreateFolder, () => true, null, 20));

            var shaderFolder = AddFolder("Shader", 82);

            foreach (var entry in UnityScriptTemplates.Entries)
            {
                string itemName;
                var    parent = EnsureByPath(entry.Path, entry.Priority, out itemName);
                AddScriptTemplate(itemName, entry.Priority, entry.FileName, entry.TemplatePath, parent);
            }
            AddInternal(typeof(ShaderVariantCollection), "Shader Variant Collection", 94, "New Shader Variant Collection.shadervariants", () => new ShaderVariantCollection(), shaderFolder);

            entries.Add(new Entry("Scene", ProjectWindowUtil.CreateScene, () => true, null, 201, typeof(Scene)));

#if !UNITY_2018_3_OR_NEWER
            entries.Add(new Entry("Prefab", ProjectWindowUtil.CreatePrefab, () => true, null, 202));
#endif

            var createAudioMixer =
                typeof(ProjectWindowUtil).GetMethod("CreateAudioMixer", BindingFlags.NonPublic | BindingFlags.Static);

            entries.Add(new Entry("Audio Mixer", () => { createAudioMixer.Invoke(null, null); }, () => true, null, 215, typeof(AudioMixer)));

            AddInternal(typeof(Material), "Material", 301, "New Material.mat", () => new Material(Shader.Find("Standard")));
            AddInternal(typeof(Flare), "Lens Flare", 303, "New Lens Flare.flare", () => new Flare());
            AddInternal(typeof(RenderTexture), "Render Texture", 304, "New Render Texture.renderTexture", () => new RenderTexture(256, 256, 24));
            AddInternal(typeof(LightmapParameters), "Lightmap Parameters", 305, "New Lightmap Parameters.giparams", () => new LightmapParameters());
            AddInternal(typeof(CustomRenderTexture), "Custom Render Texture", 306, "New Custom Render Texture.asset", () => new CustomRenderTexture(256, 256));

            // not sure what is exact version
#if UNITY_2018_2_OR_NEWER
            AddInternal(typeof(SpriteAtlas), "Sprite Atlas", 351, "New Sprite Atlas.spriteatlas", () => new SpriteAtlas());
#else
            AddInternal(typeof(SpriteAtlas), "Sprite Atlas", 351, "New Sprite Atlas.spriteatlas", () => Activator.CreateInstance <SpriteAtlas>());
#endif
            var sprites = AddFolder("Sprites", 352);

            CreateSpritePolygonType createSprite =
                new InternalGetter <CreateSpritePolygonType>(typeof(ProjectWindowUtil), "CreateSpritePolygon").Func;

            sprites.Children.Add(new Entry("Square", () => createSprite(0), () => true, sprites, 352, typeof(Sprite)));
            sprites.Children.Add(new Entry("Triangle", () => createSprite(3), () => true, sprites, 352, typeof(Sprite)));
            sprites.Children.Add(new Entry("Diamond", () => createSprite(4), () => true, sprites, 352, typeof(Sprite)));
            sprites.Children.Add(new Entry("Hexagon", () => createSprite(6), () => true, sprites, 352, typeof(Sprite)));
            sprites.Children.Add(new Entry("Circle", () => createSprite(128), () => true, sprites, 352, typeof(Sprite)));
            sprites.Children.Add(new Entry("Polygon", () => createSprite(7), () => true, sprites, 352, typeof(Sprite)));

            AddInternal(typeof(AnimatorController), "Animator Controller", 401, "New Animator Controller.controller", () => new AnimatorController());
            AddInternal(typeof(AnimationClip), "Animation", 402, "New Animation.anim", () => new AnimationClip());
            AddInternal(typeof(AnimatorOverrideController), "Animator Override Controller", 403, "New Animator Override Controller.overrideController", () => new AnimatorOverrideController());
            AddInternal(typeof(AvatarMask), "Avatar Mask", 404, "New Avatar Mask.mask", () => new AvatarMask());

            AddInternal(typeof(PhysicMaterial), "Physics Material", 501, "New Physic Material.asset", () => new PhysicMaterial());
            AddInternal(typeof(PhysicsMaterial2D), "Physics Material 2D", 502, "New Physic Material 2D.asset", () => new PhysicsMaterial2D());

            AddInternal(typeof(Font), "Custom Font", 602, "New Font.fontsettings", () => new Font());

            var legacy = AddFolder("Legacy", 850);
            AddInternal(typeof(Cubemap), "Cubemap", 850, "New Cubemap.cubemap", () => new Cubemap(64, TextureFormat.RGBAFloat, true), legacy);
        }