echo3D
🌐 Back to website💻 Go to console📺 Watch workshop💬 Discuss on Slack
  • Introduction
  • Quickstart
    • 🔑Register
    • 💻Access the Console
    • 🎲Add a 3D Asset
    • 📤Share it with Others
    • ❔Troubleshooting
  • Web Console
    • 📦Load a Collection
    • 💼Manage Pages
      • Content Page
        • Assets and Targets
        • Add Content
        • Edit Content
        • Share Content
        • Access Permissions
        • Version Control
        • Asset Hierarchy
        • Bulk Actions on Assets
        • Asset Commenting
        • Activity Sidebar
      • Metadata & Tags Page
        • Collection Taxonomy and Asset Specific Metadata
        • How to Add and Edit Metadata
        • How to Add Associated Files and Text
      • Collections and Sharing Page
        • Users Tab
        • Groups Tab
        • Collections
        • Collection Sharing Tab
        • Asset Sharing Tab
        • Security Tab
      • Customizer Page
      • Model Editor Page
      • Scene Editor Page
    • 🚚Deliver Pages
      • Locations Page
      • Users Page
      • Insights Page
    • 🕛Optimize Pages
      • Convert & Compress Page
    • 🎓Learn Pages
      • Tutorials Page
    • 👤Account Page
      • Profile Tab
      • Email & Password
      • Plans Tab
      • Credit Usage Tab
      • Notifications Tab
      • Delete Account Tab
    • ❓Help Menu
    • ⏬Downloads
    • 🎨Themes
    • 🔎Search
  • API
    • 🧩Objects
    • 🗨️Queries
    • 📊Data
      • 📑What Metadata is Stored
    • 🔼Upload
    • 🔽Download
    • ❌Delete
    • 🌳Entry Hierarchy
    • 🔄Convert
    • 🔃Compress
    • 📁Organize
    • ⏪Version
    • ⏬Locate
    • 🔎Search
    • 🖼️Search by Image or Model
    • Share Content
  • Unity
    • 🔨Installation
    • 🧰Using the SDK
    • 🔧Script Settings
    • 📐Transforming Content
    • 👩‍💻Edit Code
    • 🤳Adding AR Capabilities
    • ❔Troubleshooting
  • Unreal 4
    • 🔨Installation
    • 🧰Using the SDK
    • 🔧Demo Project
  • Web
    • 🔨Installation
    • 🧰Using the Package
  • Scene Viewer
    • 📲Deploy Experience
    • 📐Transforming Content
    • 🔢Embed into Website or App
    • 👩‍💻Add Code
    • ❔Troubleshooting
  • AR.js
    • 📲Deploy Experience
    • 📐Transforming Content
    • 🔢Embed into Website or App
    • ❔Troubleshooting
  • FaceAR
    • 📲Deploy Experience
    • 📐Transforming Content
    • 🔢Embed into Website or App
    • ❔Troubleshooting
  • React Native
    • 📩Fetching Data
    • 👩‍💻Edit Code
    • 🤳Adding AR/VR Capabilities
    • 📐Transforming Content
  • Swift
    • 🔨Installation
    • 🔢Displaying a Model Asset
    • 🤳Adding AR Capabilities
    • 🧰Using the SDK
  • Flutter
    • 🔨Installation
    • 👩‍💻Edit Code
    • 🤳Adding AR Capabilities
  • JavaScript
    • 🔨Installation
    • 🧰Using the SDK
    • 📩Fetching Data
    • 👩‍💻Edit Code
  • Python
    • 🔨Installation
    • 🧰Using the SDK
    • 🔧Demo Project
  • NVIDIA Omniverse
    • 🔨Installation
  • Adobe Substance 3D Painter
    • 🔨Installation
  • 🧰Using the Plugin
  • Blender
    • 🔨Installation
    • 🧰Using the Add-on
  • eCommerce Sites
    • 🛒Shopify
    • 🌐Wix
  • 3D Content
    • 🎨Content Creation
    • 💎Google Poly
    • 📦Objaverse
    • 💫3D Capture Apps
      • MagiScan
      • Qlone
      • ARitize360
      • SCANN3D
      • 3D Scanner
      • Didimo Xperience
      • Scaniverse
      • Metascan3D
      • Polycam3D
      • RealityScan
Powered by GitBook
On this page
  • Code Example
  • Querying Metadata
  • Posting Metadata
  • Subscribing for Metadata Changes

Was this helpful?

  1. Unity

Edit Code

Learn how to add code to your Unity project while getting data from the cloud.

Now that you are able to successfully stream the 3D model into Unity, it's time to make some custom adjustments.

Each asset will be instantiated with a script named CustomBehaviour.cs attached. You can edit this script to create any behavior you would like while referencing additional data streamed from the cloud.

Code Example

From the project's packages folder, open the /co.echo3d.unity/Runtime/CustomBehaviour.cs script:

CustomBehaviour.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CustomBehaviour : MonoBehaviour
{
    [HideInInspector]
    public Entry entry;

    /// <summary>
    /// EXAMPLE BEHAVIOUR
    /// Queries the database and names the object based on the result.
    /// </summary>

    // Use this for initialization
    void Start()
    {
        // Add RemoteTransformations script to object and set its entry
        this.gameObject.AddComponent<RemoteTransformations>().entry = entry;

        // ADD YOUR CODE HERE //
        // Qurey additional data to get the name
        string value = "";
        if (entry.getAdditionalData() != null && 
            entry.getAdditionalData().TryGetValue("name", out value))
        {
            // Set name
            this.gameObject.name = value;
        }
    }

    // Update is called once per frame
    void Update()
    {

    }
}

Note that this is an regular Unity MonoBehaviour with additions to the Start() function.

// Add RemoteTransformations script to object and set its entry
this.gameObject.AddComponent<RemoteTransformations>().entry = entry;

You can add any custom code after line 21. An example follows.

Querying Metadata

Lines 22-28 are an example that queries the entry's metadata for a key called name, and if such key exists, set the game object's name to the corresponding value:

string value = "";
if (entry.getAdditionalData() != null && 
    entry.getAdditionalData().TryGetValue("name", out value))
{
    // Set name
    this.gameObject.name = value;
}

Without the name key being set, the default game object's name is the asset filename.

key

value

name

empire_state

Run Unity again and notice that the game object name automatically changes.

Great work! 🎉

Posting Metadata

In order to call this function from any other script you can use the Echo3DService instance to callUpdateEntryData function with this single line of code:

Echo3DService.instance.UpdateEntryData("<ENTRY_ID>", "<DATA>", "<VALUE>");

Where <ENTRY_ID> is the a specific entry ID you are trying to post metadata too, <DATA> is the data key (e.g. scale), and <VALUE> is the data value (e.g. 2).

Subscribing for Metadata Changes

Add the following code to your Start function to register an action that will be executed when metadata is received from the cloud.

// Define data action
WClient.On(WClient.EventType.DATA_POST_ENTRY.ToString(), (string message) => {
    
    // Parse data
    string[] messageArray = message.Split('|');
    string dataKey = messageArray[2];
    string dataValue = messageArray[3];
    
    // Add you code here
    // myFunction(dataKey, dataValue);
    
});
PreviousTransforming ContentNextAdding AR Capabilities

Last updated 1 year ago

Was this helpful?

Lines 18-19 attaches a RemoteTransformations component to the game object and sets its content entry. This component is in charge of enabling .

Use the console to entry with the following data:

Built-in keywords will be suggested through a drop-down list but you can any key and any value by typing it in the text input field.

You can add metadata to the cloud or update existing metadata stored remotely by calling the UpdateEntryData function located in the echo3D.cs script. This function implements the API query.

👩‍💻
set a metadata
add
real-time updates and animations
Post Metadata to an Entry