Unity - API Interface
A guide on interfacing with the DTLab API through the Unity Editor in order to retrieve models and projects from the graphDB for use in Unity projects.
Server Integration Basics
Introduction
The Unity Server Integration package comprises three main components: LoginManager
, LoginEditorWindow
, and AuthTokenManager
. Together, these scripts provide a solution for authenticating Unity users, fetching data from a server, and managing authentication tokens within the Unity Editor.
-
LoginManager: Responsible for interfacing directly with the server. It sends login credentials, retrieves user data, models, and projects.
-
LoginEditorWindow: Provides a user-friendly GUI within the Unity Editor for users to input their credentials, initiate server requests, and view fetched data.
-
AuthTokenManager: A utility class that centrally manages the authentication token, ensuring secure storage and easy access for server requests.
Key Functionalities
-
User Authentication:
- Users can input their
username
andpassword
within theLoginEditorWindow
. - Upon confirming,
LoginManager
sends the credentials to the server. - Successful authentication returns a token, stored using
AuthTokenManager
.
- Users can input their
-
Fetching Data:
- Once authenticated, users can fetch models, projects, and their user data via buttons in the
LoginEditorWindow
. - The data retrieval is handled by
LoginManager
, which sends requests to the server using the token fromAuthTokenManager
. - Fetched data is displayed within the
LoginEditorWindow
.
- Once authenticated, users can fetch models, projects, and their user data via buttons in the
-
Token Management:
-
AuthTokenManager
provides a centralized way to store and retrieve the authentication token. - The token is essential for making authenticated requests to the server after the initial login.
-
Workflow
- Open the
LoginEditorWindow
viaTools > Login Manager
in the Unity Editor. - Input your
username
andpassword
, then click "Confirm". - Upon successful login, the authentication token is stored.
- Use the "Fetch Models/Projects" and "Fetch User Data" buttons to retrieve data from the server.
- View the fetched data directly within the
LoginEditorWindow
.