コード例 #1
0
        private static CreateGameObjectOption Asset(AssetDatabaseEntry assetDatabaseEntry)
        {
            var option = new CreateGameObjectOption();

            option.assetDatabaseEntry = assetDatabaseEntry;
            option.label   = assetDatabaseEntry.name;
            option.getIcon = option.GetAssetIcon;
            return(option);
        }
コード例 #2
0
        public static CreateGameObjectOption Primitive(string primitivePath)
        {
            var option = new CreateGameObjectOption();

            option.primitivePath = primitivePath;
            option.label         = primitivePath.PartAfterLast(EditorMainMenu.Separator).TrimStart("Create ");
            option.value         = option.CreatePrimitive;
            option.getIcon       = () => PeekPlugin.Icons.createGameObject;
            return(option);
        }
コード例 #3
0
        private static CreateGameObjectOption Asset(HierarchyPropertyCache assetDatabaseEntry)
        {
            var option = new CreateGameObjectOption();

            option.assetDatabaseEntry = assetDatabaseEntry;
            option.label       = assetDatabaseEntry.name;
            option.getIcon     = option.GetAssetIcon;
            option.assetPath   = assetDatabaseEntry.assetPath;
            option.assetFolder = PathUtility.NaiveNormalize(Path.GetDirectoryName(option.assetPath));
            return(option);
        }
コード例 #4
0
        public override void Prewarm()
        {
            base.Prewarm();

            UnityAPI.Await
            (
                () =>
            {
                if (PeekPlugin.Configuration.createPrimitives)
                {
                    var primitivePaths = EditorMainMenu
                                         .GetSubmenus("GameObject")
                                         .Where(mi => !(createMenuBlacklist.Contains(mi) || PeekPlugin.Configuration.createMenuBlacklist.Contains(mi)))
                                         .ToArray();

                    var primitiveFolders = HashSetPool <string> .New();

                    foreach (var primitivePath in primitivePaths)
                    {
                        var primitiveOption = CreateGameObjectOption.Primitive(primitivePath);
                        var primitiveFolder = primitiveOption.primitiveFolder;

                        primitiveOptions.Add(primitiveOption);

                        if (!primitiveFolders.Contains(primitiveFolder))
                        {
                            primitiveFolderOptions.Add(new MenuFolderOption(primitiveFolder));
                            primitiveFolders.Add(primitiveFolder);
                        }
                    }

                    primitiveFolders.Free();
                }

                if (PeekPlugin.Configuration.createPrefabs)
                {
                    foreach (var prefabResult in AssetDatabaseUtility.FindAssets("t:prefab"))
                    {
                        assetOptions.Add(CreateGameObjectOption.Prefab(prefabResult));
                    }
                }

                if (PeekPlugin.Configuration.createModels)
                {
                    foreach (var modelResult in AssetDatabaseUtility.FindAssets("t:model"))
                    {
                        assetOptions.Add(CreateGameObjectOption.Model(modelResult));
                    }
                }

                if (PeekPlugin.Configuration.createSprites)
                {
                    foreach (var spriteResult in AssetDatabaseUtility.FindAssets("t:sprite"))
                    {
                        assetOptions.Add(CreateGameObjectOption.Sprite(spriteResult));
                    }
                }

                var assetFolders = HashSetPool <string> .New();

                foreach (var assetOption in assetOptions)
                {
                    var assetFolder = assetOption.assetFolder;

                    if (!assetFolders.Contains(assetFolder))
                    {
                        assetFolderOptions.Add(new AssetFolderOption(assetFolder));
                        assetFolders.Add(assetFolder);
                    }
                }

                assetFolders.Free();
            }
            );
        }