private void PopulateSdkBuilders()
    {
        if (_sdkBuilders != null)
        {
            return;
        }
        List <IVRCSdkControlPanelBuilder> builders = new List <IVRCSdkControlPanelBuilder>();

        foreach (Type type in GetSdkBuilderTypesFromAttribute())
        {
            IVRCSdkControlPanelBuilder builder = (IVRCSdkControlPanelBuilder)Activator.CreateInstance(type);
            builder.RegisterBuilder(this);
            builders.Add(builder);
        }
        _sdkBuilders = builders.ToArray();
    }
 private void ShowSettingsOptionsForBuilders()
 {
     if (_sdkBuilders == null)
     {
         PopulateSdkBuilders();
     }
     for (int i = 0; i < _sdkBuilders.Length; i++)
     {
         IVRCSdkControlPanelBuilder builder = _sdkBuilders[i];
         builder.ShowSettingsOptions();
         if (i < _sdkBuilders.Length - 1)
         {
             EditorGUILayout.Separator();
         }
     }
 }
    void ShowBuilders()
    {
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.BeginVertical();

        if (VRC.Core.ConfigManager.RemoteConfig.IsInitialized())
        {
            string sdkUnityVersion = VRC.Core.ConfigManager.RemoteConfig.GetString("sdkUnityVersion");
            if (Application.unityVersion != sdkUnityVersion)
            {
                OnGUIWarning(null, "You are not using the recommended Unity version for the VRChat SDK. Content built with this version may not work correctly. Please use Unity " + sdkUnityVersion,
                             null,
                             () => { Application.OpenURL("https://unity3d.com/get-unity/download/archive"); }
                             );
            }
        }

        if (VRCSdk3Analysis.IsSdkDllActive(VRCSdk3Analysis.SdkVersion.VRCSDK2) && VRCSdk3Analysis.IsSdkDllActive(VRCSdk3Analysis.SdkVersion.VRCSDK3))
        {
            List <Component> sdk2Components = VRCSdk3Analysis.GetSDKInScene(VRCSdk3Analysis.SdkVersion.VRCSDK2);
            List <Component> sdk3Components = VRCSdk3Analysis.GetSDKInScene(VRCSdk3Analysis.SdkVersion.VRCSDK3);
            if (sdk2Components.Count > 0 && sdk3Components.Count > 0)
            {
                OnGUIError(null,
                           "This scene contains components from the VRChat SDK version 2 and version 3. Version two elements will have to be replaced with their version 3 counterparts to build with SDK3 and UDON.",
                           () => { Selection.objects = sdk2Components.ToArray(); },
                           null
                           );
            }
        }

        if (Lightmapping.giWorkflowMode == Lightmapping.GIWorkflowMode.Iterative)
        {
            OnGUIWarning(null,
                         "Automatic lightmap generation is enabled, which may stall the Unity build process. Before building and uploading, consider turning off 'Auto Generate' at the bottom of the Lighting Window.",
                         () =>
            {
                EditorWindow lightingWindow = GetLightingWindow();
                if (lightingWindow)
                {
                    lightingWindow.Show();
                    lightingWindow.Focus();
                }
            },
                         () =>
            {
                Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.OnDemand;
                EditorWindow lightingWindow = GetLightingWindow();
                if (!lightingWindow)
                {
                    return;
                }
                lightingWindow.Repaint();
                Focus();
            }
                         );
        }

        PopulateSdkBuilders();
        IVRCSdkControlPanelBuilder selectedBuilder = null;
        string errorMessage = null;

        foreach (IVRCSdkControlPanelBuilder sdkBuilder in _sdkBuilders)
        {
            if (!sdkBuilder.IsValidBuilder(out string message))
            {
                if (selectedBuilder == null)
                {
                    errorMessage = message;
                }
            }
            else
            {
                if (selectedBuilder == null)
                {
                    selectedBuilder = sdkBuilder;
                    errorMessage    = null;
                }
                else
                {
                    errorMessage =
                        "A Unity scene cannot contain a VRChat Scene Descriptor and also contain VRChat Avatar Descriptors";
                }
            }
        }
        if (selectedBuilder == null)
        {
#if VRC_SDK_VRCSDK2
            EditorGUILayout.LabelField("A VRC_SceneDescriptor or VRC_AvatarDescriptor\nis required to build VRChat SDK Content", titleGuiStyle, GUILayout.Width(SdkWindowWidth));
#elif VRC_SDK_VRCSDK3
            EditorGUILayout.LabelField("A VRCSceneDescriptor or VRCAvatarDescriptor\nis required to build VRChat SDK Content", titleGuiStyle, GUILayout.Width(SdkWindowWidth));
#endif
        }
        else if (errorMessage != null)
        {
            OnGUIError(null,
                       errorMessage,
                       () => {
                foreach (IVRCSdkControlPanelBuilder builder in _sdkBuilders)
                {
                    builder.SelectAllComponents();
                }
            },
                       null
                       );
            OnGUIShowIssues();
        }
        else
        {
            selectedBuilder.ShowBuilder();
        }

        if (Event.current.type == EventType.Used)
        {
            return;
        }
        GUILayout.EndVertical();
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
    }