Logging Into the Platform #
In this section, we’ll be logging in with the configured SDK. Note that this method of logging in is useful during development but is not appropriate for use in production.
Create the login script #
make runto start Pragma Engine. Run this in a terminal with
platformas the working directory.
Alternatively, Pragma Engine can be run from IntelliJ. From the IntelliJ toolbar in the upper right, ensure
MainKt - LocalConfiguredis selected, then click the play button.
Once the engine has successfully started it prints the message
[main] INFO main - Pragma server startup complete.
Scriptsfolder in your
Assetsfolder. Create a new C# script named
PragmaManager.csand open it.
Paste the following code into the
In this code block:
- Add all the connection state change lambdas in the
- Add a
Login()method which we will hook up to a button later in this guide.
Link the login script to a button #
Return to your Unity project. Right click in an empty part of the Hierarchy pane on the left side, click Create Empty, and name the
PragmaManager.csscript onto the
Right click in the Hierarchy pane and select UI then Button.
Expand the Button object in the Hierarchy pane and select Text.
In the Inspector pane, find the Text box with the default text of
Button. Rename it by typing
In the Hierarchy pane, click on the Button object.
In the On Click (), select the + sign, and drag
PragmaManagerfrom the Hierarchy pane onto None (Object) in the Inspector pane. Click No Function and select PragmaManager, then Login().
Log in #
Click play, then click the Login button to connect to your locally running Pragma Engine instance.
Navigate to Pragma Portal. Select Sign in with Pragma Unsafe and type in test04.
Find the entry with the Player id for test01 from logging in via Unity.
Return to your Unity project and scroll through the console messages until you find the “LOG IN SUCCESS!” message with a Player id.
Compare the Player ids from steps 3 and 4, and confirm that they match.
All other Pragma Engine API calls from
PragmaSessionare available once logged in.