|
|
|
|
|
|
/// </summary>
|
|
|
|
public struct NamedPrefab |
|
|
|
{ |
|
|
|
Guid m_ImageGuid; |
|
|
|
[SerializeField] |
|
|
|
string m_ImageGuid; |
|
|
|
public Guid imageGuid |
|
|
|
public string imageGuid |
|
|
|
get => m_ImageGuid; |
|
|
|
get => m_ImageGuid; |
|
|
|
} |
|
|
|
|
|
|
|
[SerializeField] |
|
|
|
|
|
|
{ |
|
|
|
get => m_Prefab; |
|
|
|
get => m_Prefab; |
|
|
|
public NamedPrefab(Guid imageGuid, GameObject prefab) |
|
|
|
public NamedPrefab(Guid guid, GameObject prefab) |
|
|
|
m_ImageGuid = imageGuid; |
|
|
|
m_ImageGuid = guid.ToString(); |
|
|
|
m_Prefab = prefab; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
Dictionary<Guid, GameObject> m_PrefabsDictionary = new Dictionary<Guid, GameObject>(); |
|
|
|
ARTrackedImageManager m_TrackedImageManager; |
|
|
|
|
|
|
|
|
|
|
|
[SerializeField] |
|
|
|
[Tooltip("Reference Image Library")] |
|
|
|
XRReferenceImageLibrary m_ImageLibrary; |
|
|
|
|
|
|
void Awake() |
|
|
|
{ |
|
|
|
m_TrackedImageManager = GetComponent<ARTrackedImageManager>(); |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
m_PrefabsDictionary.Add(ImageLibrary[i].guid, prefabList[i].prefab); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
{ |
|
|
|
if (library) |
|
|
|
{ |
|
|
|
if (m_PrefabList == null) |
|
|
|
if (prefabList == null) |
|
|
|
m_PrefabList = new List<NamedPrefab>(); |
|
|
|
prefabList = new List<NamedPrefab>(); |
|
|
|
m_PrefabList.Add(new NamedPrefab(library[i].guid, null)); |
|
|
|
prefabList.Add(new NamedPrefab(library[i].guid, null)); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
|
|
|
{ |
|
|
|
var idx = m_PrefabList.FindIndex(item => item.imageGuid == library[i].guid); |
|
|
|
tempList.Add(new NamedPrefab(library[i].guid, (idx != -1) ? m_PrefabList[idx].prefab : null)); |
|
|
|
var idx = prefabList.FindIndex(item => item.imageGuid == library[i].guid.ToString()); |
|
|
|
tempList.Add(new NamedPrefab(library[i].guid, (idx != -1) ? prefabList[idx].prefab : null)); |
|
|
|
m_PrefabList = tempList; |
|
|
|
prefabList = tempList; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void OnTrackedImagesChanged(ARTrackedImagesChangedEventArgs eventArgs) |
|
|
|
|
|
|
// Give the initial image a reasonable default scale
|
|
|
|
trackedImage.transform.localScale = new Vector3(trackedImage.size.x/2, trackedImage.size.x/2, trackedImage.size.x/2); |
|
|
|
trackedImage.transform.localScale = new Vector3(trackedImage.size.x / 2, trackedImage.size.x / 2, trackedImage.size.x / 2); |
|
|
|
|
|
|
|
AssignPrefab(trackedImage); |
|
|
|
} |
|
|
|
|
|
|
{ |
|
|
|
if (m_PrefabsDictionary.TryGetValue(trackedImage.referenceImage.guid, out GameObject prefab)){ |
|
|
|
if (m_PrefabsDictionary.TryGetValue(trackedImage.referenceImage.guid, out GameObject prefab)) |
|
|
|
{ |
|
|
|
#if UNITY_EDITOR
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
|
|
|
[CustomEditor(typeof(MultiTrackedImageInfoManager))] |
|
|
|
public class MultiTrackedImageInfoManagerInspector : Editor |
|
|
|
|
|
|
if (EditorGUI.EndChangeCheck()) |
|
|
|
behaviour.OnLibraryChanged(library); |
|
|
|
else if (HasLibraryChanged(library)) |
|
|
|
behaviour.OnLibraryChanged(library); |
|
|
|
behaviour.OnLibraryChanged(library); |
|
|
|
// Update current
|
|
|
|
// update current
|
|
|
|
m_ReferenceImages.Clear(); |
|
|
|
if (library) |
|
|
|
{ |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
serializedObject.ApplyModifiedProperties(); |
|
|
|
Undo.RecordObject(target, "Sync Library"); |
|
|
|
EditorUtility.SetDirty(target); |
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
} |
|
|
|
} |