Skip to main content

Getting Started

Installation

  • You can find .unitypackage file at
https://github.com/Realistic3D/real_api_unity/releases

Usage

  • Add login class
    • Add class RealAPI to any active gameObject and add your login information
using REAL;
using REAL.Networks;

[RequireComponent(typeof(RealAPI))]
public class RendererScene : MonoBehaviour
{
public RealAPI real;

private void Awake()
{
real = GetComponent<RealAPI>();
}
}

Step 1:

Get scene

  • You can render whole scene or even some gameObjects of your scene it depends upon your requirement
// Step 1: Get scene from whole Scene

Camera camera = myCam; // Optional
Scene scene = myScene; // Required
var realScene = Real.RealScene(scene, camera);

OR

// Step 1: Get scene from some gameobjects in Scene

Camera camera = myCam; // Optional
List<GameObject> allObjects = requiredObject; // Required
var realScene = Real.RealScene(allObjects, camera);

Note

  • camera is an Optional parameter in this function.
  • If you have multiple cameras in scene or list , the camera you want to render can be named as RealEYE or you can bypass directly to the function Real.RealScene(allObjects, camera)

Step 2:

Create new job

// Step 2: Apply new job

var apiResponse = await ApiRequests.PostRequest(login, RequestService.New);
var resData = apiResponse.data;
var uri = resData.url;

Step 3:

Upload scene

 // Step 3: Upload scene

bool uploaded = await ApiRequests.PutRequest(uri, realScene);

Step 4:

Submit job

// Step 4: Render job

await ApiRequests.PostRequest(login, RequestService.Render, resData.jobID);

Final script

using REAL;
using REAL.Networks;
using UnityEngine;
using UnityEngine.SceneManagement;

[RequireComponent(typeof(RealAPI))]
public class RendererScene : MonoBehaviour
{
public RealAPI real;

private void Awake()
{
real = GetComponent<RealAPI>();
}

public async void RenderScene()
{
var login = real.login;

// Step 1: Get Scene

var camera = Camera.main;
var scene = SceneManager.GetActiveScene();
var realScene = Real.RealScene(scene, camera);

// Step 2: Apply new job

var apiResponse = await ApiRequests.PostRequest(login, RequestService.New);
var resData = apiResponse.data;
var uri = resData.url;

// Step 3: Upload scene

bool uploaded = await ApiRequests.PutRequest(uri, realScene);

// Step 4: Render job

await ApiRequests.PostRequest(login, RequestService.Render, resData.jobID);
}
}

Connect socket

You can check the example at REAL.Example.RealSocket You can create any UI button (or however you wish to call socket) and use following example to connect socket

public void ConnectSocketClick()
{
Commons.Renderer.canvas.infoPanel.SetStatus("Connecting....");
REAL.Example.RealSocket.Connect();
}

Socket url:

var uri = $"wss://{(RealNetwork.Domain)}/realAPI?app_key={appKey}&prod_key={prodKey}&ins_id={insID}&exp_from=u3d";

Get product details:

var prodInfo = await ApiRequests.LoginProduct(Commons.Renderer.real.login);

example