Unity 3D
Installation
You can find .unitypackage file at https://github.com/Realistic3D/real_api_unity/releases
Render
1. Add login class
Add class
RealAPIto any activegameObjectand 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>();
    }
}
Get Real API scene (binary 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:
camerais an Optional parameter in this function.If you have multiple
Camerain scene or list , the camera you want to render can be named asREAL_EYEor you can bypass directly to the functionReal.RealScene(allObjects, camera)
Create new job
// Step 2: Apply new job
var apiResponse = await ApiRequests.PostRequest(login, AskService.NewJob);
var resData = apiResponse.data; 
var uri = resData.url;Upload scene
// Step 3: Upload scene
bool uploaded = await ApiRequests.PutRequest(uri, realScene);Submit job
// Step 4: Submit job
await ApiRequests.PostRequest(login, AskService.Submit, 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, AskService.NewJob);
        var resData = apiResponse.data; 
        var uri = resData.url;
        
        // Step 3: Upload scene
        bool uploaded = await ApiRequests.PutRequest(uri, realScene);
        
        // Step 4: Submit job
        await ApiRequests.PostRequest(login, AskService.Submit, resData.jobID);
    }
}
Last updated