Editor/BuilderHelper.cs
/// <summary>
/// Find all Builder assets. Offers to create one if none is found. Selects if only one is found.
/// Opens up a window with all available builders if more then one exists in the project.
/// </summary>
Find all Builder assets. Offers to create one if none is found. Selects if only one is found.
Opens up a window with all available builders if more then one exists in the project.
Find all Builder assets . Offers to create one if none is found . Selects if only one is found . Opens up a window with all available builders if more then one exists in the project .
[MenuItem("Extra Tools/Builder")]
        private static void GetBuilder()
        {
            var builders = AssetDatabase.FindAssets("t:Builder");
            for (int i = 0; i < builders.Length; i++)
            {
                builders[i] = AssetDatabase.GUIDToAssetPath(builders[i]);
            }
            if (builders.Length == 0)
            {
                bool answer = EditorUtility.DisplayDialog("No builder assets in project!",
                    $"Could not find any asset of type 'Builder' in project. Do you want to create one?", "Sure",
                    "Nah, I'm OK");
                if (answer)
                {
                    CreateBuilderAsset();
                }
                return;
            }
            if (builders.Length == 1)
            {
                SelectObject(builders[0]);
                return;
            }
            SelectBuilder.ShowWindow(builders);
        }
[ MenuItem ( " " ) ] private static void GetBuilder ( ) { var builders = AssetDatabase . FindAssets ( " " ) ; for ( int i = 0 ; i < builders . Length ; i ++ ) { builders [ i ] = AssetDatabase . GUIDToAssetPath ( builders [ i ] ) ; } if ( builders . Length == 0 ) { bool answer = EditorUtility . DisplayDialog ( " " , $" Could not find any asset of type 'Builder' in project. Do you want to create one? " , " " , " " ) ; if ( answer ) { CreateBuilderAsset ( ) ; } return ; } if ( builders . Length == 1 ) { SelectObject ( builders [ 0 ] ) ; return ; } SelectBuilder . ShowWindow ( builders ) ; }
Find all Builder assets.
Find all Builder assets .