Skip to content

Commit

Permalink
Merge pull request #9 from didimoinc/release/4.0.1
Browse files Browse the repository at this point in the history
Release/4.0.1
  • Loading branch information
Hugo-Pereira authored Apr 5, 2022
2 parents aa59381 + 9f07854 commit 680c313
Show file tree
Hide file tree
Showing 2,107 changed files with 75,672 additions and 2,822,434 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ This SDK has been built to work with Unity 2020.3.x LTS (from Unity 2020.3.12 on
1. Install via the package manager
1. Open Unity's Package Manager
2. Under the `+` button, select `Add package from git URL...`
3. Enter `https://github.com/didimoinc/didimo-digital-human-unity-sdk.git?path=/com.didimo.sdk.core#4.0.0` and press `Add`
3. Enter `https://github.com/didimoinc/didimo-digital-human-unity-sdk.git?path=/com.didimo.sdk.core#4.0.1` and press `Add`
4. Optionally, add any of the following modules, by repeating the previous 2 steps, with the URLs:

* `https://github.com/didimoinc/didimo-digital-human-unity-sdk.git?path=/com.didimo.sdk.networking#4.0.0` For didimo API integration
* `https://github.com/didimoinc/didimo-digital-human-unity-sdk.git?path=/com.didimo.sdk.mobile#4.0.0` For a communication layer between android/iOS and Unity
* `https://github.com/didimoinc/didimo-digital-human-unity-sdk.git?path=/com.didimo.sdk.oculus#4.0.0` For integration with Oculus
* `https://github.com/didimoinc/didimo-digital-human-unity-sdk.git?path=/com.didimo.sdk.networking#4.0.1` For didimo API integration
* `https://github.com/didimoinc/didimo-digital-human-unity-sdk.git?path=/com.didimo.sdk.mobile#4.0.1` For a communication layer between android/iOS and Unity
* `https://github.com/didimoinc/didimo-digital-human-unity-sdk.git?path=/com.didimo.sdk.oculus#4.0.1` For integration with Oculus


2. Setup your project. You can do this by going to Didimo → Didimo Manager, and following the instructions, or by following these steps
Expand Down
30 changes: 21 additions & 9 deletions com.didimo.sdk.core/Editor/DidimoManager/CoreDidimoManagerTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.PackageManager.UI;
using UnityEngine;
using UnityEngine.SceneManagement;

namespace Didimo.Core.Editor
{
Expand Down Expand Up @@ -67,16 +69,26 @@ public void FixIssueButton(IProjectSettingIssue check)

public static async void OpenMeetADidimo()
{
await PackageUtility.ImportSampleAndLoadScene("com.didimo.sdk.core",
"Core Samples",
"MeetADidimo/MeetADidimo.unity",
success =>
Sample? sample = await PackageUtility.GetSample("com.didimo.sdk.core", "Core Samples");
bool isImported = sample != null && sample!.Value.isImported;
if (!isImported && sample != null)
{
if (!PackageUtility.ImportSample(sample!.Value))
{
if (success)
{
EditorApplication.isPlaying = true;
}
});
return;
}
}

if (sample != null && PackageUtility.LoadSceneFromSample(sample!.Value, "MeetADidimo/MeetADidimo.unity"))
{
#if UNITY_EDITOR_OSX
EditorUtility.DisplayDialog("Re-open Scene",
"There is a Unity bug where the first time we open this scene, it doesn't de-serialize properly. If you see errors in the console, please exit play mode, re-open the (MeetADidimo) scene manually , and hit play to see didimos in action.",
"OK");
#endif

EditorApplication.EnterPlaymode();
}
}

public override string GetTabName() => "Getting Started";
Expand Down
2 changes: 1 addition & 1 deletion com.didimo.sdk.core/Editor/GLTFImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Didimo.Core.Editor
{
[ScriptedImporter(5, "gltf", importQueueOffset: 100)]
[ScriptedImporter(6, "gltf", importQueueOffset: 100)]
public class GLTFImporter : ScriptedImporter
{
public ImportSettings importSettings;
Expand Down
67 changes: 49 additions & 18 deletions com.didimo.sdk.core/Editor/Utility/PackageUtility.cs
Original file line number Diff line number Diff line change
@@ -1,60 +1,91 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Unity.EditorCoroutines.Editor;
using UnityEditor;
using UnityEditor.PackageManager;
using UnityEditor.PackageManager.Requests;
using UnityEditor.PackageManager.UI;
using UnityEngine;
using UnityEngine.SceneManagement;
using PackageInfo = UnityEditor.PackageManager.PackageInfo;

namespace Didimo.Core.Editor
{
public static class PackageUtility
{
public static async Task ImportSampleAndLoadScene(string packageName, string sampleName, string scenePath, [CanBeNull] Action<bool> onCompletion = null)
public static async Task<Sample?> GetSample(string packageName, string sampleName)
{
try
{
EditorUtility.DisplayProgressBar("Importing sample...", "Please wait while we import the sample", 0);
EditorUtility.DisplayProgressBar("Fetching sample...", "Please wait while we fetch the sample", 0);
ListRequest request = Client.List();

while (!request.IsCompleted) await Task.Delay(100);
if (request.Status == StatusCode.Failure)
{
onCompletion?.Invoke(false);
return;
return null;
}

PackageInfo package = request.Result.First(p => p.name == packageName);
EditorUtility.DisplayProgressBar("Importing sample...", "Please wait while we import the sample", .5f);

Sample sample = Sample.FindByPackage(package.name, package.version).FirstOrDefault(s => string.IsNullOrEmpty(sampleName) || s.displayName == sampleName);
string importPath = sample.importPath.Replace("\\", "/").Remove(0, Application.dataPath.Length + 1);
sample.Import();
string path = $"Assets/{importPath}/{scenePath}";

SceneAsset obj = AssetDatabase.LoadAssetAtPath(path, typeof(SceneAsset)) as SceneAsset;
Selection.activeObject = obj;
EditorGUIUtility.PingObject(obj);
return sample;
}
finally
{
EditorUtility.ClearProgressBar();
}
}

public static bool ImportSample(Sample sample)
{
try
{
EditorUtility.DisplayProgressBar("Importing sample...", "Please wait while we import the sample", 1);

sample.Import();
AssetDatabase.Refresh();

UnityEditor.SceneManagement.EditorSceneManager.OpenScene(path);
onCompletion?.Invoke(true);
EditorUtility.DisplayProgressBar("Importing sample...", "Please wait while we import the sample", 1);
}
catch (Exception e)
{
Debug.LogException(e);
onCompletion?.Invoke(false);
return false;
}
finally
{
EditorUtility.ClearProgressBar();
}

return true;
}

public static string GetSceneAssetPath(Sample sample, string scenePath)
{
string importPath = sample.importPath.Replace("\\", "/").Remove(0, Application.dataPath.Length + 1);
return $"Assets/{importPath}/{scenePath}";
}

public static bool LoadSceneFromSample(Sample sample, string scenePath)
{
try
{
string path = GetSceneAssetPath(sample, scenePath);

SceneAsset obj = AssetDatabase.LoadAssetAtPath(path, typeof(SceneAsset)) as SceneAsset;
Selection.activeObject = obj;
EditorGUIUtility.PingObject(obj);

UnityEditor.SceneManagement.EditorSceneManager.OpenScene(path);
return true;
}
catch (Exception e)
{
Debug.LogException(e);
return false;
}
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 680c313

Please sign in to comment.