├── .gitattributes
├── CustomBehaviour.cs
├── LICENSE.md
├── README.md
├── assets
├── Face Template.pptx
├── face-1.jpg
└── face-2.jpg
└── images
├── Console.png
├── Face-Change.gif
├── Face-Change.mp4
└── Phone.gif
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/CustomBehaviour.cs:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | * Copyright (C) echoAR, Inc. 2018-2020. *
3 | * echoAR, Inc. proprietary and confidential. *
4 | * *
5 | * Use subject to the terms of the Terms of Service available at *
6 | * https://www.echoar.xyz/terms, or another agreement *
7 | * between echoAR, Inc. and you, your company or other organization. *
8 | ***************************************************************************/
9 | using System.Collections;
10 | using System.Collections.Generic;
11 | using UnityEngine;
12 | using UnityEngine.XR.ARFoundation;
13 |
14 | public class CustomBehaviour : MonoBehaviour
15 | {
16 | [HideInInspector]
17 | public Entry entry;
18 |
19 | ///
20 | /// EXAMPLE BEHAVIOUR
21 | /// Queries the database and names the object based on the result.
22 | ///
23 |
24 | // Use this for initialization
25 | void Start()
26 | {
27 | // Add RemoteTransformations script to object and set its entry
28 | this.gameObject.AddComponent().entry = entry;
29 |
30 | // Qurey additional data to get the name
31 | string value = "";
32 | if (entry.getAdditionalData() != null && entry.getAdditionalData().TryGetValue("name", out value))
33 | {
34 | // Set name
35 | this.gameObject.name = value;
36 | }
37 | }
38 |
39 | // Update is called once per frame
40 | void Update()
41 | {
42 | // Set image holgram as face texture
43 | Hologram hologram = entry.getHologram();
44 | Hologram.hologramType hologramType = hologram.getType();
45 | // Check for image hologram
46 | if (hologramType == Hologram.hologramType.IMAGE_HOLOGRAM){
47 | // Get mesh renderer
48 | MeshRenderer meshRenderer = this.GetComponent();
49 | // Get material and texture
50 | Material material = meshRenderer.material;
51 | Texture texture = material.mainTexture;
52 | // Get session and face switcher
53 | GameObject session = GameObject.Find("AR Session Origin");
54 | FaceMaterialSwitcher faceMaterialSwitcher = session.GetComponentInChildren();
55 | // Set material and texture
56 | if (faceMaterialSwitcher != null) {
57 | // Set materials (overwrite all other face materials)
58 | int size = faceMaterialSwitcher.faceMaterials.Length;
59 | faceMaterialSwitcher.faceMaterials = new Material[ size ];
60 | for (int i = 0; i < size; i++) faceMaterialSwitcher.faceMaterials[i] = material;
61 | }
62 | }
63 | }
64 | }
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright © echoAR, Inc. 2018-2020.
2 |
3 | Use subject to the Terms of Service available at https://www.echoar.xyz/terms, or another agreement between echoAR, Inc. and you, your company or other organization.
4 |
5 | Unless expressly provided otherwise, the software provided under these Terms of Service is made available strictly on an “AS IS” BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. Please review the Terms of Service for details on these and other terms and conditions.
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Unity-ARFoundation-echo3D-demo-Face-Change
2 | Simple face change demo with Unity, AR Foundation, and echo3D
3 |
4 | ## Register
5 | Don't have an API key? Make sure to register for FREE at [echo3D](https://console.echo3D.co/#/auth/register).
6 |
7 | ## Setup
8 | * Create a new Unity project.
9 | * Clone the [Unity-ARFoundation-echo3D](https://github.com/echo3Dco/Unity-ARFoundation-echo3D) sample code.
10 | * Open the sample scence under `AR Foundation\Scenes\FaceTracking\FaceMesh.unity`.
11 | * [Set the API key](https://docs.echo3D.co/unity/using-the-sdk) in the `echo3D.cs` script inside the `echo3D\echo3D.prefab` using the the Inspector.
12 | * [Add an image hologram](https://docs.echo3D.co/web-console/manage-pages/content-page/how-to-add-content) by uploding one of the _face-#.jpg_ files from the [assets](./assets/) folder to the console.
13 | * Overwrite the existing _echo3D/CustomBehaviour.cs_ script with the new [_CustomBehaviour.cs_](./CustomBehaviour.cs) file.
14 |
15 | ## Build & Run
16 | * [Build and run the AR application](https://docs.echo3D.co/unity/adding-ar-capabilities#4-build-and-run-the-ar-application). Verify that the `AR Foundation\Scenes\FaceTracking\FaceMesh` scene is ticked in the `Scenes in Build` list and click `Build And Run`.
17 |
18 | ## Learn more
19 | Refer to our [documentation](https://docs.echo3D.co/unity/) to learn more about how to use Unity and echo3D.
20 |
21 | ## Support
22 | Feel free to reach out at [support@echo3D.co](mailto:support@echo3D.co) or join our [support channel on Slack](https://go.echo3D.co/join).
23 |
24 | ## Screenshots
25 | 
26 | 
27 |
--------------------------------------------------------------------------------
/assets/Face Template.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/echo3Dco/Unity-ARFoundation-echo3D-demo-Face-Change/2cbdbc0485909b93096af253133a1feccc0292ad/assets/Face Template.pptx
--------------------------------------------------------------------------------
/assets/face-1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/echo3Dco/Unity-ARFoundation-echo3D-demo-Face-Change/2cbdbc0485909b93096af253133a1feccc0292ad/assets/face-1.jpg
--------------------------------------------------------------------------------
/assets/face-2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/echo3Dco/Unity-ARFoundation-echo3D-demo-Face-Change/2cbdbc0485909b93096af253133a1feccc0292ad/assets/face-2.jpg
--------------------------------------------------------------------------------
/images/Console.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/echo3Dco/Unity-ARFoundation-echo3D-demo-Face-Change/2cbdbc0485909b93096af253133a1feccc0292ad/images/Console.png
--------------------------------------------------------------------------------
/images/Face-Change.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/echo3Dco/Unity-ARFoundation-echo3D-demo-Face-Change/2cbdbc0485909b93096af253133a1feccc0292ad/images/Face-Change.gif
--------------------------------------------------------------------------------
/images/Face-Change.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/echo3Dco/Unity-ARFoundation-echo3D-demo-Face-Change/2cbdbc0485909b93096af253133a1feccc0292ad/images/Face-Change.mp4
--------------------------------------------------------------------------------
/images/Phone.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/echo3Dco/Unity-ARFoundation-echo3D-demo-Face-Change/2cbdbc0485909b93096af253133a1feccc0292ad/images/Phone.gif
--------------------------------------------------------------------------------