关于标题的问题。我创建了一个 Steam 应用程序,并使用 Steamworks.NET
进行 Steam 初始化。网站说:
Open the Visual Studio solution (.sln) file, build both targets one for Windows and one for OSX & Linux. (Optional if you downloaded a prebuilt version) Reference the built assembly (Steamworks.NET.dll) in your project. Start coding! Call SteamAPI.Init() before initializing your renderer.
我尝试用加载事件调用它,但每次都崩溃了。
这里是我的调用代码:
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) {
SteamAPI.Init();
SteamAPI.RestartAppIfNecessary(new AppId_t(911310));
}
我试过:
public MainWindow()
{
SteamAPI.Init();
InitializeComponent();
}
如何在渲染前调用该方法?
已解决
使用不同的 SDK 解决。
最佳答案
使用 Application.Startup
事件。
您可以像这样将其附加到“App.xaml”文件中:
<Application
x:Class="SomeApp.App.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SomeApp.App"
Startup="App_OnStartup">
<Application.Resources>
</Application.Resources>
</Application>
然后在“App.xaml.cs”中添加处理程序:
public partial class App : Application
{
private void App_OnStartup(object sender, StartupEventArgs e)
{
SteamAPI.Init();
}
}
关于c# - 如何在初始化渲染器之前调用方法 [Wpf],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51523131/