Skip to content
Snippets Groups Projects
Commit 7eff7bfe authored by Samuel Truman's avatar Samuel Truman
Browse files

Added spawn dialogs logic

parent c176d8f2
No related branches found
No related tags found
No related merge requests found
......@@ -1268,53 +1268,57 @@ PrefabInstance:
propertyPath: m_Name
value: Dialog New
objectReference: {fileID: 0}
- target: {fileID: 583540011480971668, guid: a13c970a539c3c946a6d098aa571ead3, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1235909505916248863, guid: a13c970a539c3c946a6d098aa571ead3, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1235909505916248863, guid: a13c970a539c3c946a6d098aa571ead3, type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1235909505916248863, guid: a13c970a539c3c946a6d098aa571ead3, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 130
objectReference: {fileID: 0}
- target: {fileID: 1235909505916248863, guid: a13c970a539c3c946a6d098aa571ead3, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -30
objectReference: {fileID: 0}
- target: {fileID: 3107749895110523315, guid: a13c970a539c3c946a6d098aa571ead3, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3107749895110523315, guid: a13c970a539c3c946a6d098aa571ead3, type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3107749895110523315, guid: a13c970a539c3c946a6d098aa571ead3, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 150
objectReference: {fileID: 0}
- target: {fileID: 3107749895110523315, guid: a13c970a539c3c946a6d098aa571ead3, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -87
objectReference: {fileID: 0}
- target: {fileID: 4585156439228018145, guid: a13c970a539c3c946a6d098aa571ead3, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4585156439228018145, guid: a13c970a539c3c946a6d098aa571ead3, type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4585156439228018145, guid: a13c970a539c3c946a6d098aa571ead3, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 150
objectReference: {fileID: 0}
- target: {fileID: 4585156439228018145, guid: a13c970a539c3c946a6d098aa571ead3, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -29.5
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a13c970a539c3c946a6d098aa571ead3, type: 3}
using System.Collections.Generic;
using System.Linq;
using Articy.Unity;
using de.jmu.ge.SpokeSceneImporter;
using de.jmu.ge.viavr.dialogs.runtime;
using Newtonsoft.Json;
using UnityEditor;
using UnityEngine;
using UnityEngine.Assertions;
public class DialogConfigurator : de.jmu.ge.viavr.UnityBridge.Core.PackageConfigurator {
private const ulong testArticyDialogId = 0x1_00_00_00_00_00_00_3E; // TODO: for testing only. Remove once the logic engine defines the list of dialogs.
namespace de.jmu.ge.viavr.dialogs.editor {
public class DialogConfigurator : de.jmu.ge.viavr.UnityBridge.Core.PackageConfigurator {
private const string dialogPrefabPath = "Packages/de.jmu.ge.dialogsystem/Prefabs/Dialog New.prefab";
private Vector3 dialogSpawnOffset = new Vector3(0, 1f, 0);
public override void OnConfigureScene() {
var prefab = AssetDatabase.LoadAssetAtPath<GameObject>("Packages/de.jmu.ge.dialogsystem/Prefabs/Dialog.prefab");
Assert.AreNotEqual(prefab, null);
var instance = PrefabUtility.InstantiatePrefab(prefab) as GameObject;
instance.GetComponent<ArticyFlowPlayer>().StartOn = ArticyDatabase.GetObject(testArticyDialogId);
[MenuItem("Tools/Test Spawn Dialogs")]
public static void TestSpawnDialogs() {
var instance = new DialogConfigurator();
instance.OnConfigureScene();
}
public override void OnConfigureScene() {
LoadDialogPrefab(out var dialogPrefab);
LoadBuildSettings(out var buildSettings);
List<AvatarData> avatars = buildSettings?["avatars"]?.ToObject<List<AvatarData>>();
if(avatars == null || avatars.Count == 0) return;
var allUuids = Object.FindObjectsOfType<Uuid>();
// spawn dialog prefab for each avatar
foreach(var avatar in avatars) {
var avatarObj = allUuids.FirstOrDefault(id => avatar.sceneObject == id.serializedUuid)?.gameObject;
if(avatarObj == null) continue;
var dialogObj = PrefabUtility.InstantiatePrefab(dialogPrefab) as GameObject;
dialogObj.transform.SetParent(avatarObj.transform);
dialogObj.transform.position = avatarObj.transform.position + dialogSpawnOffset;
// config dialog
// instance.GetComponent<ArticyFlowPlayer>().StartOn = ArticyDatabase.GetObject(testArticyDialogId);
}
}
private static void LoadBuildSettings(out dynamic buildSettings) {
var buildSettingsText = Resources.Load("BuildSettings").ToString();
buildSettings = JsonConvert.DeserializeObject(buildSettingsText);
}
private static void LoadDialogPrefab(out GameObject prefab) {
prefab = AssetDatabase.LoadAssetAtPath<GameObject>(dialogPrefabPath);
Assert.AreNotEqual(prefab, null);
}
}
}
\ No newline at end of file
}
......@@ -3,7 +3,8 @@
"rootNamespace": "",
"references": [
"GUID:53aad864d9d5c8647935c5f382f2af43",
"GUID:c1a0b8bdc821d98478ffd9adf27fc584"
"GUID:c1a0b8bdc821d98478ffd9adf27fc584",
"GUID:e0d4b2b655f35f44aad543ce2dad4372"
],
"includePlatforms": [
"Editor"
......
namespace de.jmu.ge.viavr.dialogs.runtime {
public class AvatarData {
public string articyId;
public string name;
public string token;
public string sceneObject;
public string dialogId;
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: ffbd9316b38a4fcb95bd9e1cab357289
timeCreated: 1699542557
\ No newline at end of file
......@@ -11,7 +11,8 @@
"documentationUrl": "https://gitlab2.informatik.uni-wuerzburg.de/GE/Dev/ViaVR/components/dialog-system/-/wikis/Documentation",
"hideInEditor": false,
"dependencies": {
"de.jmu.ge.viavr.unitybridge": "0.4.0"
"de.jmu.ge.viavr.unitybridge": "0.4.0",
"de.jmu.ge.spokesceneimporter": "0.3.3"
},
"samples": [
{
......
......@@ -287,7 +287,8 @@
"depth": 0,
"source": "embedded",
"dependencies": {
"de.jmu.ge.viavr.unitybridge": "0.4.0"
"de.jmu.ge.viavr.unitybridge": "0.4.0",
"de.jmu.ge.spokesceneimporter": "0.3.3"
}
},
"de.jmu.ge.spokesceneimporter": {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment